@takaro/db 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/migrations/sql/20251101000000-add-deleted-domain-state.d.ts +4 -0
- package/dist/migrations/sql/20251101000000-add-deleted-domain-state.d.ts.map +1 -0
- package/dist/migrations/sql/20251101000000-add-deleted-domain-state.js +33 -0
- package/dist/migrations/sql/20251101000000-add-deleted-domain-state.js.map +1 -0
- package/package.json +1 -1
- package/src/migrations/sql/20251101000000-add-deleted-domain-state.ts +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20251101000000-add-deleted-domain-state.d.ts","sourceRoot":"","sources":["../../../src/migrations/sql/20251101000000-add-deleted-domain-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,wBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBlD;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBpD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export async function up(knex) {
|
|
2
|
+
// PostgreSQL requires a multi-step process to update enum constraints
|
|
3
|
+
// 1. Add a temporary column with the new enum values
|
|
4
|
+
// 2. Copy data from old column to new column
|
|
5
|
+
// 3. Drop old column
|
|
6
|
+
// 4. Rename new column to old column name
|
|
7
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
8
|
+
table.enum('state_new', ['ACTIVE', 'DISABLED', 'MAINTENANCE', 'DELETED']).notNullable().defaultTo('ACTIVE');
|
|
9
|
+
});
|
|
10
|
+
await knex.raw(`UPDATE domains SET state_new = state::text::varchar`);
|
|
11
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
12
|
+
table.dropColumn('state');
|
|
13
|
+
});
|
|
14
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
15
|
+
table.renameColumn('state_new', 'state');
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export async function down(knex) {
|
|
19
|
+
// Revert to the original enum values (removing DELETED)
|
|
20
|
+
// First, ensure no domains are in DELETED state (or this will fail)
|
|
21
|
+
await knex.raw(`DELETE FROM domains WHERE state = 'DELETED'`);
|
|
22
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
23
|
+
table.enum('state_new', ['ACTIVE', 'DISABLED', 'MAINTENANCE']).notNullable().defaultTo('ACTIVE');
|
|
24
|
+
});
|
|
25
|
+
await knex.raw(`UPDATE domains SET state_new = state::text::varchar`);
|
|
26
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
27
|
+
table.dropColumn('state');
|
|
28
|
+
});
|
|
29
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
30
|
+
table.renameColumn('state_new', 'state');
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=20251101000000-add-deleted-domain-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20251101000000-add-deleted-domain-state.js","sourceRoot":"","sources":["../../../src/migrations/sql/20251101000000-add-deleted-domain-state.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,IAAU;IACjC,sEAAsE;IACtE,qDAAqD;IACrD,6CAA6C;IAC7C,qBAAqB;IACrB,0CAA0C;IAE1C,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC9G,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IAEtE,MAAM,IAAI,CAAC,MAA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SQL requires a multi-step process to update enum constraints
|
|
5
|
+
// 1. Add a temporary column with the new enum values
|
|
6
|
+
// 2. Copy data from old column to new column
|
|
7
|
+
// 3. Drop old column
|
|
8
|
+
// 4. Rename new column to old column name
|
|
9
|
+
|
|
10
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
11
|
+
table.enum('state_new', ['ACTIVE', 'DISABLED', 'MAINTENANCE', 'DELETED']).notNullable().defaultTo('ACTIVE');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
await knex.raw(`UPDATE domains SET state_new = state::text::varchar`);
|
|
15
|
+
|
|
16
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
17
|
+
table.dropColumn('state');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
21
|
+
table.renameColumn('state_new', 'state');
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function down(knex: Knex): Promise<void> {
|
|
26
|
+
// Revert to the original enum values (removing DELETED)
|
|
27
|
+
// First, ensure no domains are in DELETED state (or this will fail)
|
|
28
|
+
await knex.raw(`DELETE FROM domains WHERE state = 'DELETED'`);
|
|
29
|
+
|
|
30
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
31
|
+
table.enum('state_new', ['ACTIVE', 'DISABLED', 'MAINTENANCE']).notNullable().defaultTo('ACTIVE');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await knex.raw(`UPDATE domains SET state_new = state::text::varchar`);
|
|
35
|
+
|
|
36
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
37
|
+
table.dropColumn('state');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
await knex.schema.alterTable('domains', (table) => {
|
|
41
|
+
table.renameColumn('state_new', 'state');
|
|
42
|
+
});
|
|
43
|
+
}
|