@takaro/db 0.4.11 → 0.4.12

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.
@@ -0,0 +1,4 @@
1
+ import { Knex } from 'knex';
2
+ export declare function up(knex: Knex): Promise<void>;
3
+ export declare function down(knex: Knex): Promise<void>;
4
+ //# sourceMappingURL=20251115071948-remove-deleted-domain-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20251115071948-remove-deleted-domain-state.d.ts","sourceRoot":"","sources":["../../../src/migrations/sql/20251115071948-remove-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,CAuBlD;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBpD"}
@@ -0,0 +1,35 @@
1
+ export async function up(knex) {
2
+ // First, migrate any existing DELETED domains to DISABLED state
3
+ await knex.raw(`UPDATE domains SET state = 'DISABLED' WHERE state = 'DELETED'`);
4
+ // PostgreSQL requires a multi-step process to update enum constraints
5
+ // 1. Add a temporary column with the new enum values (without DELETED)
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
+ await knex.schema.alterTable('domains', (table) => {
10
+ table.enum('state_new', ['ACTIVE', 'DISABLED', 'MAINTENANCE']).notNullable().defaultTo('ACTIVE');
11
+ });
12
+ await knex.raw(`UPDATE domains SET state_new = state::text::varchar`);
13
+ await knex.schema.alterTable('domains', (table) => {
14
+ table.dropColumn('state');
15
+ });
16
+ await knex.schema.alterTable('domains', (table) => {
17
+ table.renameColumn('state_new', 'state');
18
+ });
19
+ }
20
+ export async function down(knex) {
21
+ // Drop the enum type if it exists to prevent "type already exists" errors
22
+ await knex.raw('DROP TYPE IF EXISTS state_new CASCADE');
23
+ // Revert to include DELETED in enum values
24
+ await knex.schema.alterTable('domains', (table) => {
25
+ table.enum('state_new', ['ACTIVE', 'DISABLED', 'MAINTENANCE', 'DELETED']).notNullable().defaultTo('ACTIVE');
26
+ });
27
+ await knex.raw(`UPDATE domains SET state_new = state::text::varchar`);
28
+ await knex.schema.alterTable('domains', (table) => {
29
+ table.dropColumn('state');
30
+ });
31
+ await knex.schema.alterTable('domains', (table) => {
32
+ table.renameColumn('state_new', 'state');
33
+ });
34
+ }
35
+ //# sourceMappingURL=20251115071948-remove-deleted-domain-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20251115071948-remove-deleted-domain-state.js","sourceRoot":"","sources":["../../../src/migrations/sql/20251115071948-remove-deleted-domain-state.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,IAAU;IACjC,gEAAgE;IAChE,MAAM,IAAI,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;IAEhF,sEAAsE;IACtE,uEAAuE;IACvE,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,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnG,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IAEtE,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAU;IACnC,0EAA0E;IAC1E,MAAM,IAAI,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;IAExD,2CAA2C;IAC3C,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,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAChD,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@takaro/db",
3
3
  "description": "An opinionated data layer",
4
- "version": "0.4.11",
4
+ "version": "0.4.12",
5
5
  "author": "",
6
6
  "dependencies": {
7
- "class-validator": "0.14.2",
7
+ "class-validator": "0.14.3",
8
8
  "knex": "3.1.0",
9
9
  "ms": "2.1.3",
10
10
  "objection": "3.1.5",
@@ -0,0 +1,46 @@
1
+ import { Knex } from 'knex';
2
+
3
+ export async function up(knex: Knex): Promise<void> {
4
+ // First, migrate any existing DELETED domains to DISABLED state
5
+ await knex.raw(`UPDATE domains SET state = 'DISABLED' WHERE state = 'DELETED'`);
6
+
7
+ // PostgreSQL requires a multi-step process to update enum constraints
8
+ // 1. Add a temporary column with the new enum values (without DELETED)
9
+ // 2. Copy data from old column to new column
10
+ // 3. Drop old column
11
+ // 4. Rename new column to old column name
12
+
13
+ await knex.schema.alterTable('domains', (table) => {
14
+ table.enum('state_new', ['ACTIVE', 'DISABLED', 'MAINTENANCE']).notNullable().defaultTo('ACTIVE');
15
+ });
16
+
17
+ await knex.raw(`UPDATE domains SET state_new = state::text::varchar`);
18
+
19
+ await knex.schema.alterTable('domains', (table) => {
20
+ table.dropColumn('state');
21
+ });
22
+
23
+ await knex.schema.alterTable('domains', (table) => {
24
+ table.renameColumn('state_new', 'state');
25
+ });
26
+ }
27
+
28
+ export async function down(knex: Knex): Promise<void> {
29
+ // Drop the enum type if it exists to prevent "type already exists" errors
30
+ await knex.raw('DROP TYPE IF EXISTS state_new CASCADE');
31
+
32
+ // Revert to include DELETED in enum values
33
+ await knex.schema.alterTable('domains', (table) => {
34
+ table.enum('state_new', ['ACTIVE', 'DISABLED', 'MAINTENANCE', 'DELETED']).notNullable().defaultTo('ACTIVE');
35
+ });
36
+
37
+ await knex.raw(`UPDATE domains SET state_new = state::text::varchar`);
38
+
39
+ await knex.schema.alterTable('domains', (table) => {
40
+ table.dropColumn('state');
41
+ });
42
+
43
+ await knex.schema.alterTable('domains', (table) => {
44
+ table.renameColumn('state_new', 'state');
45
+ });
46
+ }