rake-db 2.3.30 → 2.3.32

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.
Files changed (57) hide show
  1. package/dist/index.d.ts +10 -22
  2. package/dist/index.js +6 -6
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +6 -6
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +12 -22
  7. package/.env +0 -1
  8. package/.env.local +0 -2
  9. package/.turbo/turbo-check.log +0 -23
  10. package/.turbo/turbo-test.log +0 -22
  11. package/.turbo/turbo-test:ci.log +0 -22
  12. package/CHANGELOG.md +0 -395
  13. package/app/dbScript.ts +0 -33
  14. package/app/migrations/20221017181504_createUser.ts +0 -14
  15. package/app/migrations/20221017200111_createProfile.ts +0 -10
  16. package/app/migrations/20221017200252_createChat.ts +0 -9
  17. package/app/migrations/20221017200326_createChatUser.ts +0 -10
  18. package/app/migrations/20221017200900_createMessage.ts +0 -12
  19. package/app/migrations/20221017201235_createGeoSchema.ts +0 -5
  20. package/app/migrations/20221017210011_createCountry.ts +0 -8
  21. package/app/migrations/20221017210133_createCity.ts +0 -9
  22. package/app/migrations/20221105202843_createUniqueTable.ts +0 -12
  23. package/jest-setup.ts +0 -3
  24. package/rollup.config.js +0 -3
  25. package/src/ast.ts +0 -130
  26. package/src/commands/createOrDrop.test.ts +0 -214
  27. package/src/commands/createOrDrop.ts +0 -151
  28. package/src/commands/generate.test.ts +0 -136
  29. package/src/commands/generate.ts +0 -93
  30. package/src/commands/migrateOrRollback.test.ts +0 -267
  31. package/src/commands/migrateOrRollback.ts +0 -190
  32. package/src/common.test.ts +0 -295
  33. package/src/common.ts +0 -353
  34. package/src/errors.ts +0 -3
  35. package/src/index.ts +0 -8
  36. package/src/migration/change.test.ts +0 -16
  37. package/src/migration/change.ts +0 -15
  38. package/src/migration/changeTable.test.ts +0 -897
  39. package/src/migration/changeTable.ts +0 -566
  40. package/src/migration/createTable.test.ts +0 -384
  41. package/src/migration/createTable.ts +0 -193
  42. package/src/migration/migration.test.ts +0 -430
  43. package/src/migration/migration.ts +0 -518
  44. package/src/migration/migrationUtils.ts +0 -307
  45. package/src/migration/tableMethods.ts +0 -8
  46. package/src/pull/astToMigration.test.ts +0 -275
  47. package/src/pull/astToMigration.ts +0 -173
  48. package/src/pull/dbStructure.test.ts +0 -180
  49. package/src/pull/dbStructure.ts +0 -413
  50. package/src/pull/pull.test.ts +0 -115
  51. package/src/pull/pull.ts +0 -22
  52. package/src/pull/structureToAst.test.ts +0 -841
  53. package/src/pull/structureToAst.ts +0 -372
  54. package/src/rakeDb.test.ts +0 -131
  55. package/src/rakeDb.ts +0 -84
  56. package/src/test-utils.ts +0 -64
  57. package/tsconfig.json +0 -12
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ declare const tableChangeMethods: {
23
23
  nonNullable(): Change;
24
24
  comment(comment: string | null): Change;
25
25
  rename(name: string): RakeDbAst.ChangeTableItem.Rename;
26
- raw: (sql: string, values?: false | Record<string, unknown> | undefined) => RawExpression<ColumnType<unknown, pqb.BaseOperators, unknown>>;
26
+ raw: (sql: string, values?: false | Record<string, unknown> | undefined) => RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>;
27
27
  enum: (name: string) => EnumColumn<string, [string, ...string[]]>;
28
28
  };
29
29
  declare type TableChanger = MigrationColumnTypes & TableChangeMethods;
@@ -102,7 +102,7 @@ declare const createMigrationInterface: (tx: TransactionAdapter, up: boolean, op
102
102
  xml: () => pqb.XMLColumn;
103
103
  json: <Type extends pqb.JSONTypeAny>(schemaOrFn: Type | ((j: {
104
104
  set: <Value extends pqb.JSONTypeAny>(valueType: Value) => pqb.JSONSet<Value>;
105
- tuple: <T_1 extends pqb.JSONTupleItems | [], Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
105
+ tuple: <T_1 extends [] | pqb.JSONTupleItems, Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
106
106
  union: <T_2 extends [pqb.JSONTypeAny, pqb.JSONTypeAny, ...pqb.JSONTypeAny[]]>(types: T_2) => pqb.JSONUnion<T_2>;
107
107
  any: () => pqb.JSONAny;
108
108
  bigint: () => pqb.JSONBigInt;
@@ -140,12 +140,8 @@ declare const createMigrationInterface: (tx: TransactionAdapter, up: boolean, op
140
140
  timestamps: <T_14 extends ColumnType<unknown, pqb.BaseOperators, unknown>>(this: {
141
141
  timestamp(): T_14;
142
142
  }) => {
143
- createdAt: T_14 & {
144
- hasDefault: true;
145
- };
146
- updatedAt: T_14 & {
147
- hasDefault: true;
148
- };
143
+ createdAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
144
+ updatedAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
149
145
  };
150
146
  primaryKey(columns: string[], options?: {
151
147
  name?: string | undefined;
@@ -201,7 +197,7 @@ declare const createMigrationInterface: (tx: TransactionAdapter, up: boolean, op
201
197
  xml: () => pqb.XMLColumn;
202
198
  json: <Type extends pqb.JSONTypeAny>(schemaOrFn: Type | ((j: {
203
199
  set: <Value extends pqb.JSONTypeAny>(valueType: Value) => pqb.JSONSet<Value>;
204
- tuple: <T_1 extends pqb.JSONTupleItems | [], Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
200
+ tuple: <T_1 extends [] | pqb.JSONTupleItems, Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
205
201
  union: <T_2 extends [pqb.JSONTypeAny, pqb.JSONTypeAny, ...pqb.JSONTypeAny[]]>(types: T_2) => pqb.JSONUnion<T_2>;
206
202
  any: () => pqb.JSONAny;
207
203
  bigint: () => pqb.JSONBigInt;
@@ -239,12 +235,8 @@ declare const createMigrationInterface: (tx: TransactionAdapter, up: boolean, op
239
235
  timestamps: <T_14 extends ColumnType<unknown, pqb.BaseOperators, unknown>>(this: {
240
236
  timestamp(): T_14;
241
237
  }) => {
242
- createdAt: T_14 & {
243
- hasDefault: true;
244
- };
245
- updatedAt: T_14 & {
246
- hasDefault: true;
247
- };
238
+ createdAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
239
+ updatedAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
248
240
  };
249
241
  primaryKey(columns: string[], options?: {
250
242
  name?: string | undefined;
@@ -299,7 +291,7 @@ declare const createMigrationInterface: (tx: TransactionAdapter, up: boolean, op
299
291
  xml: () => pqb.XMLColumn;
300
292
  json: <Type extends pqb.JSONTypeAny>(schemaOrFn: Type | ((j: {
301
293
  set: <Value extends pqb.JSONTypeAny>(valueType: Value) => pqb.JSONSet<Value>;
302
- tuple: <T_1 extends pqb.JSONTupleItems | [], Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
294
+ tuple: <T_1 extends [] | pqb.JSONTupleItems, Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
303
295
  union: <T_2 extends [pqb.JSONTypeAny, pqb.JSONTypeAny, ...pqb.JSONTypeAny[]]>(types: T_2) => pqb.JSONUnion<T_2>;
304
296
  any: () => pqb.JSONAny;
305
297
  bigint: () => pqb.JSONBigInt;
@@ -337,12 +329,8 @@ declare const createMigrationInterface: (tx: TransactionAdapter, up: boolean, op
337
329
  timestamps: <T_14 extends ColumnType<unknown, pqb.BaseOperators, unknown>>(this: {
338
330
  timestamp(): T_14;
339
331
  }) => {
340
- createdAt: T_14 & {
341
- hasDefault: true;
342
- };
343
- updatedAt: T_14 & {
344
- hasDefault: true;
345
- };
332
+ createdAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
333
+ updatedAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
346
334
  };
347
335
  primaryKey(columns: string[], options?: {
348
336
  name?: string | undefined;
package/dist/index.js CHANGED
@@ -301,7 +301,7 @@ const columnToSql = (key, item, values, hasMultiplePrimaryKeys) => {
301
301
  if (item.data.collate) {
302
302
  line.push(`COLLATE ${pqb.quote(item.data.collate)}`);
303
303
  }
304
- if (item.isPrimaryKey && !hasMultiplePrimaryKeys) {
304
+ if (item.data.isPrimaryKey && !hasMultiplePrimaryKeys) {
305
305
  line.push("PRIMARY KEY");
306
306
  } else if (!item.data.isNullable) {
307
307
  line.push("NOT NULL");
@@ -528,7 +528,7 @@ const createTable$1 = async (migration, up, tableName, options, fn) => {
528
528
  const makeAst$1 = (up, tableName, shape, tableData, options, noPrimaryKey) => {
529
529
  const shapePKeys = [];
530
530
  for (const key in shape) {
531
- if (shape[key].isPrimaryKey) {
531
+ if (shape[key].data.isPrimaryKey) {
532
532
  shapePKeys.push(key);
533
533
  }
534
534
  }
@@ -552,7 +552,7 @@ const validatePrimaryKey = (ast) => {
552
552
  let hasPrimaryKey = !!((_b = (_a = ast.primaryKey) == null ? void 0 : _a.columns) == null ? void 0 : _b.length);
553
553
  if (!hasPrimaryKey) {
554
554
  for (const key in ast.shape) {
555
- if (ast.shape[key].isPrimaryKey) {
555
+ if (ast.shape[key].data.isPrimaryKey) {
556
556
  hasPrimaryKey = true;
557
557
  break;
558
558
  }
@@ -711,7 +711,7 @@ const columnTypeToColumnChange = (item) => {
711
711
  column: item,
712
712
  type: item.toSQL(),
713
713
  nullable: item.data.isNullable,
714
- primaryKey: item.isPrimaryKey
714
+ primaryKey: item.data.isPrimaryKey
715
715
  }, item.data), {
716
716
  foreignKeys
717
717
  });
@@ -816,11 +816,11 @@ const astToQueries = (ast) => {
816
816
  }
817
817
  }
818
818
  if (item.type === "add") {
819
- if (item.item.isPrimaryKey) {
819
+ if (item.item.data.isPrimaryKey) {
820
820
  addPrimaryKeys.columns.push(key);
821
821
  }
822
822
  } else if (item.type === "drop") {
823
- if (item.item.isPrimaryKey) {
823
+ if (item.item.data.isPrimaryKey) {
824
824
  dropPrimaryKeys.columns.push(key);
825
825
  }
826
826
  } else if (item.type === "change") {