Create a SQL migration file
Budget: €30 – €250 EUR
Hello,
I have a site, this site has a new version and the table schema has changed a little. I need a SQL file to change the schema of the old database into the new one and keeping the data.
See files:
- old.sql => the current database
- new.sql => what the database should look like
So I need a SQL file to run that should look like this:
ALTER TABLE `articles` CHANGE `id` `id` BIGINT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `articles` CHANGE `text` `article` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
TABLE `articles` DROP `promoted`;
TABLE `articles` DROP `cover`;
etc...
Warning:
I know some of you would like to use an automated tool. But be aware that automated tools will delete and add fields, not rename them.
Example :
Want I want :
ALTER TABLE `articles` CHANGE `text` `article` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
? I will not lose data.
What the automated tool will do :
ALTER TABLE `articles` ADD `article` longtext COLLATE utf8mb4_unicode_ci NOT NULL;
ALTER TABLE `articles` DROP `text`;
? I will lose data.
So if you use want, pls double check that your tool rename when it's needed and not just add & drop.
I have a site, this site has a new version and the table schema has changed a little. I need a SQL file to change the schema of the old database into the new one and keeping the data.
See files:
- old.sql => the current database
- new.sql => what the database should look like
So I need a SQL file to run that should look like this:
ALTER TABLE `articles` CHANGE `id` `id` BIGINT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `articles` CHANGE `text` `article` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
TABLE `articles` DROP `promoted`;
TABLE `articles` DROP `cover`;
etc...
Warning:
I know some of you would like to use an automated tool. But be aware that automated tools will delete and add fields, not rename them.
Example :
Want I want :
ALTER TABLE `articles` CHANGE `text` `article` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
? I will not lose data.
What the automated tool will do :
ALTER TABLE `articles` ADD `article` longtext COLLATE utf8mb4_unicode_ci NOT NULL;
ALTER TABLE `articles` DROP `text`;
? I will lose data.
So if you use want, pls double check that your tool rename when it's needed and not just add & drop.