Skip to content

Commit

Permalink
Merge pull request #3705 from uselagoon/fix/service_environment_migra…
Browse files Browse the repository at this point in the history
…tion

FIX: fixes migration deletion logic for duplicate environment_services
  • Loading branch information
tobybellwood authored Apr 5, 2024
2 parents 5c1fa7d + 655fb78 commit 3da6b90
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
exports.up = async function(knex) {
return knex.schema
.raw(`DELETE es1 FROM environment_service es1 INNER JOIN environment_service es2 WHERE es1.id < es2.id AND es1.name = es2.name;`)
.raw(`DELETE o FROM environment_service AS o LEFT JOIN (SELECT MIN(id) AS id FROM environment_service GROUP BY environment, name) AS i ON o.id = i.id WHERE i.id IS NULL;`)
.alterTable('environment_service', function (table) {
table.string('type', 300);
table.timestamp('updated').notNullable().defaultTo(knex.fn.now());
Expand Down

0 comments on commit 3da6b90

Please sign in to comment.