@prairielearn/migrations 2.1.0 → 3.0.1

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 (60) hide show
  1. package/.mocharc.cjs +3 -0
  2. package/CHANGELOG.md +25 -0
  3. package/dist/batched-migrations/batched-migration-job.js +18 -22
  4. package/dist/batched-migrations/batched-migration-job.js.map +1 -1
  5. package/dist/batched-migrations/batched-migration-runner.d.ts +2 -2
  6. package/dist/batched-migrations/batched-migration-runner.js +22 -26
  7. package/dist/batched-migrations/batched-migration-runner.js.map +1 -1
  8. package/dist/batched-migrations/batched-migration-runner.test.js +53 -78
  9. package/dist/batched-migrations/batched-migration-runner.test.js.map +1 -1
  10. package/dist/batched-migrations/batched-migration.js +30 -41
  11. package/dist/batched-migrations/batched-migration.js.map +1 -1
  12. package/dist/batched-migrations/batched-migrations-runner.d.ts +1 -1
  13. package/dist/batched-migrations/batched-migrations-runner.js +32 -67
  14. package/dist/batched-migrations/batched-migrations-runner.js.map +1 -1
  15. package/dist/batched-migrations/batched-migrations-runner.test.js +41 -69
  16. package/dist/batched-migrations/batched-migrations-runner.test.js.map +1 -1
  17. package/dist/batched-migrations/fixtures/20230406184103_successful_migration.js +2 -4
  18. package/dist/batched-migrations/fixtures/20230406184103_successful_migration.js.map +1 -1
  19. package/dist/batched-migrations/fixtures/20230406184107_failing_migration.d.ts +9 -0
  20. package/dist/batched-migrations/fixtures/20230406184107_failing_migration.js +14 -0
  21. package/dist/batched-migrations/fixtures/20230406184107_failing_migration.js.map +1 -0
  22. package/dist/batched-migrations/fixtures/20230407230446_no_rows_migration.js +2 -4
  23. package/dist/batched-migrations/fixtures/20230407230446_no_rows_migration.js.map +1 -1
  24. package/dist/batched-migrations/index.d.ts +3 -3
  25. package/dist/batched-migrations/index.js +3 -17
  26. package/dist/batched-migrations/index.js.map +1 -1
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +4 -22
  29. package/dist/index.js.map +1 -1
  30. package/dist/load-migrations.js +6 -16
  31. package/dist/load-migrations.js.map +1 -1
  32. package/dist/load-migrations.test.js +16 -44
  33. package/dist/load-migrations.test.js.map +1 -1
  34. package/dist/migrations/fixtures/20230407210430_insert_user.js +3 -6
  35. package/dist/migrations/fixtures/20230407210430_insert_user.js.map +1 -1
  36. package/dist/migrations/index.d.ts +1 -1
  37. package/dist/migrations/index.js +1 -5
  38. package/dist/migrations/index.js.map +1 -1
  39. package/dist/migrations/migrations.d.ts +1 -1
  40. package/dist/migrations/migrations.js +25 -57
  41. package/dist/migrations/migrations.js.map +1 -1
  42. package/dist/migrations/migrations.test.js +12 -17
  43. package/dist/migrations/migrations.test.js.map +1 -1
  44. package/package.json +14 -13
  45. package/src/batched-migrations/batched-migration-job.ts +2 -1
  46. package/src/batched-migrations/batched-migration-runner.test.ts +8 -6
  47. package/src/batched-migrations/batched-migration-runner.ts +10 -9
  48. package/src/batched-migrations/batched-migration.ts +3 -2
  49. package/src/batched-migrations/batched-migrations-runner.test.ts +15 -12
  50. package/src/batched-migrations/batched-migrations-runner.ts +7 -5
  51. package/src/batched-migrations/fixtures/20230406184103_successful_migration.ts +1 -1
  52. package/src/batched-migrations/fixtures/{20230406184107_failing_migration.js → 20230406184107_failing_migration.ts} +2 -3
  53. package/src/batched-migrations/fixtures/20230407230446_no_rows_migration.ts +1 -1
  54. package/src/batched-migrations/index.ts +7 -7
  55. package/src/index.ts +7 -7
  56. package/src/load-migrations.test.ts +6 -5
  57. package/src/migrations/index.ts +1 -1
  58. package/src/migrations/migrations.test.ts +5 -3
  59. package/src/migrations/migrations.ts +6 -5
  60. package/tsconfig.json +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"batched-migrations-runner.test.js","sourceRoot":"","sources":["../../src/batched-migrations/batched-migrations-runner.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAoC;AACpC,wEAA8C;AAC9C,0DAA6B;AAC7B,qDAA+D;AAC/D,sEAAwD;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C,uBAAuB,CAAC,kCAAkC,CAAC,CAAC;QAEzE,MAAM,aAAM,CAAC,UAAU,CACrB,MAAM,CAAC,wBAAwB,CAAC,kCAAkC,EAAE;YAClE,WAAW,EAAE,KAAK;SACnB,CAAC,EACF,oBAAoB,CACrB,CAAC;QAEF,MAAM,UAAU,GAAG,MAAM,IAAA,8CAA0B,EAAC,MAAM,CAAC,CAAC;QAC5D,aAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC/B,aAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;QACxD,aAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import chai, { assert } from 'chai';\nimport chaiAsPromised from 'chai-as-promised';\nimport path from 'node:path';\nimport { makePostgresTestUtils } from '@prairielearn/postgres';\nimport * as namedLocks from '@prairielearn/named-locks';\n\nimport { SCHEMA_MIGRATIONS_PATH, init } from '../index';\nimport { BatchedMigrationsRunner } from './batched-migrations-runner';\nimport { selectAllBatchedMigrations } from './batched-migration';\n\nchai.use(chaiAsPromised);\n\nconst postgresTestUtils = makePostgresTestUtils({\n database: 'prairielearn_migrations',\n});\n\ndescribe('BatchedMigrationsRunner', () => {\n before(async () => {\n await postgresTestUtils.createDatabase();\n await namedLocks.init(postgresTestUtils.getPoolConfig(), (err) => {\n throw err;\n });\n await init([SCHEMA_MIGRATIONS_PATH], 'prairielearn_migrations');\n });\n\n afterEach(async () => {\n await postgresTestUtils.resetDatabase();\n });\n\n after(async () => {\n await namedLocks.close();\n await postgresTestUtils.dropDatabase();\n });\n\n it('enqueues migrations', async () => {\n const runner = new BatchedMigrationsRunner({\n project: 'test',\n directories: [path.join(__dirname, 'fixtures')],\n });\n\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n await runner.enqueueBatchedMigration('20230406184107_failing_migration');\n await runner.enqueueBatchedMigration('20230407230446_no_rows_migration');\n\n const migrations = await selectAllBatchedMigrations('test');\n\n assert.lengthOf(migrations, 3);\n assert.equal(migrations[0].timestamp, '20230406184103');\n assert.equal(migrations[0].filename, '20230406184103_successful_migration.ts');\n assert.equal(migrations[0].status, 'pending');\n assert.equal(migrations[1].timestamp, '20230406184107');\n assert.equal(migrations[1].filename, '20230406184107_failing_migration.js');\n assert.equal(migrations[1].status, 'pending');\n assert.equal(migrations[2].timestamp, '20230407230446');\n assert.equal(migrations[2].filename, '20230407230446_no_rows_migration.ts');\n assert.equal(migrations[2].status, 'succeeded');\n });\n\n it('safely enqueues migrations multiple times', async () => {\n const runner = new BatchedMigrationsRunner({\n project: 'test',\n directories: [path.join(__dirname, 'fixtures')],\n });\n\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n\n const migrations = await selectAllBatchedMigrations('test');\n\n assert.lengthOf(migrations, 1);\n });\n\n it('finalizes a successful migration', async () => {\n const runner = new BatchedMigrationsRunner({\n project: 'test',\n directories: [path.join(__dirname, 'fixtures')],\n });\n\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n await runner.finalizeBatchedMigration('20230406184103_successful_migration', {\n logProgress: false,\n });\n\n const migrations = await selectAllBatchedMigrations('test');\n assert.lengthOf(migrations, 1);\n assert.equal(migrations[0].timestamp, '20230406184103');\n assert.equal(migrations[0].status, 'succeeded');\n });\n\n it('finalizes a failing migration', async () => {\n const runner = new BatchedMigrationsRunner({\n project: 'test',\n directories: [path.join(__dirname, 'fixtures')],\n });\n\n await runner.enqueueBatchedMigration('20230406184107_failing_migration');\n\n await assert.isRejected(\n runner.finalizeBatchedMigration('20230406184107_failing_migration', {\n logProgress: false,\n }),\n \"but it is 'failed'\",\n );\n\n const migrations = await selectAllBatchedMigrations('test');\n assert.lengthOf(migrations, 1);\n assert.equal(migrations[0].timestamp, '20230406184107');\n assert.equal(migrations[0].status, 'failed');\n });\n});\n"]}
1
+ {"version":3,"file":"batched-migrations-runner.test.js","sourceRoot":"","sources":["../../src/batched-migrations/batched-migrations-runner.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,CAAC,cAAc,CAAC,CAAC;AAExB,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;IAC9C,QAAQ,EAAE,yBAAyB;CACpC,CAAC,CAAC;AAEH,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,MAAM,iBAAiB,CAAC,cAAc,EAAE,CAAC;QACzC,MAAM,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;YAC/D,MAAM,GAAG,CAAC;QACZ,CAAC,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,CAAC,sBAAsB,CAAC,EAAE,yBAAyB,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,iBAAiB,CAAC,aAAa,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,KAAK,IAAI,E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nimport * as namedLocks from '@prairielearn/named-locks';\nimport { makePostgresTestUtils } from '@prairielearn/postgres';\n\nimport { SCHEMA_MIGRATIONS_PATH, init } from '../index.js';\n\nimport { selectAllBatchedMigrations } from './batched-migration.js';\nimport { BatchedMigrationsRunner } from './batched-migrations-runner.js';\n\nchaiUse(chaiAsPromised);\n\nconst postgresTestUtils = makePostgresTestUtils({\n database: 'prairielearn_migrations',\n});\n\ndescribe('BatchedMigrationsRunner', () => {\n before(async () => {\n await postgresTestUtils.createDatabase();\n await namedLocks.init(postgresTestUtils.getPoolConfig(), (err) => {\n throw err;\n });\n await init([SCHEMA_MIGRATIONS_PATH], 'prairielearn_migrations');\n });\n\n afterEach(async () => {\n await postgresTestUtils.resetDatabase();\n });\n\n after(async () => {\n await namedLocks.close();\n await postgresTestUtils.dropDatabase();\n });\n\n it('enqueues migrations', async () => {\n const runner = new BatchedMigrationsRunner({\n project: 'test',\n directories: [path.join(import.meta.dirname, 'fixtures')],\n });\n\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n await runner.enqueueBatchedMigration('20230406184107_failing_migration');\n await runner.enqueueBatchedMigration('20230407230446_no_rows_migration');\n\n const migrations = await selectAllBatchedMigrations('test');\n\n assert.lengthOf(migrations, 3);\n assert.equal(migrations[0].timestamp, '20230406184103');\n assert.equal(migrations[0].filename, '20230406184103_successful_migration.ts');\n assert.equal(migrations[0].status, 'pending');\n assert.equal(migrations[1].timestamp, '20230406184107');\n assert.equal(migrations[1].filename, '20230406184107_failing_migration.ts');\n assert.equal(migrations[1].status, 'pending');\n assert.equal(migrations[2].timestamp, '20230407230446');\n assert.equal(migrations[2].filename, '20230407230446_no_rows_migration.ts');\n assert.equal(migrations[2].status, 'succeeded');\n });\n\n it('safely enqueues migrations multiple times', async () => {\n const runner = new BatchedMigrationsRunner({\n project: 'test',\n directories: [path.join(import.meta.dirname, 'fixtures')],\n });\n\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n\n const migrations = await selectAllBatchedMigrations('test');\n\n assert.lengthOf(migrations, 1);\n });\n\n it('finalizes a successful migration', async () => {\n const runner = new BatchedMigrationsRunner({\n project: 'test',\n directories: [path.join(import.meta.dirname, 'fixtures')],\n });\n\n await runner.enqueueBatchedMigration('20230406184103_successful_migration');\n await runner.finalizeBatchedMigration('20230406184103_successful_migration', {\n logProgress: false,\n });\n\n const migrations = await selectAllBatchedMigrations('test');\n assert.lengthOf(migrations, 1);\n assert.equal(migrations[0].timestamp, '20230406184103');\n assert.equal(migrations[0].status, 'succeeded');\n });\n\n it('finalizes a failing migration', async () => {\n const runner = new BatchedMigrationsRunner({\n project: 'test',\n directories: [path.join(import.meta.dirname, 'fixtures')],\n });\n\n await runner.enqueueBatchedMigration('20230406184107_failing_migration');\n\n await assert.isRejected(\n runner.finalizeBatchedMigration('20230406184107_failing_migration', {\n logProgress: false,\n }),\n \"but it is 'failed'\",\n );\n\n const migrations = await selectAllBatchedMigrations('test');\n assert.lengthOf(migrations, 1);\n assert.equal(migrations[0].timestamp, '20230406184107');\n assert.equal(migrations[0].status, 'failed');\n });\n});\n"]}
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const batched_migration_1 = require("../batched-migration");
4
- exports.default = (0, batched_migration_1.makeBatchedMigration)({
1
+ import { makeBatchedMigration } from '../batched-migration.js';
2
+ export default makeBatchedMigration({
5
3
  async getParameters() {
6
4
  return {
7
5
  min: 1n,
@@ -1 +1 @@
1
- {"version":3,"file":"20230406184103_successful_migration.js","sourceRoot":"","sources":["../../../src/batched-migrations/fixtures/20230406184103_successful_migration.ts"],"names":[],"mappings":";;AAAA,4DAA4D;AAE5D,kBAAe,IAAA,wCAAoB,EAAC;IAClC,KAAK,CAAC,aAAa;QACjB,OAAO;YACL,GAAG,EAAE,EAAE;YACP,GAAG,EAAE,IAAI;YACT,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,IAAY,IAAG,CAAC;CAC7C,CAAC,CAAC","sourcesContent":["import { makeBatchedMigration } from '../batched-migration';\n\nexport default makeBatchedMigration({\n async getParameters() {\n return {\n min: 1n,\n max: 100n,\n batchSize: 10,\n };\n },\n\n async execute(_min: bigint, _max: bigint) {},\n});\n"]}
1
+ {"version":3,"file":"20230406184103_successful_migration.js","sourceRoot":"","sources":["../../../src/batched-migrations/fixtures/20230406184103_successful_migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,eAAe,oBAAoB,CAAC;IAClC,KAAK,CAAC,aAAa;QACjB,OAAO;YACL,GAAG,EAAE,EAAE;YACP,GAAG,EAAE,IAAI;YACT,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,IAAY,IAAG,CAAC;CAC7C,CAAC,CAAC","sourcesContent":["import { makeBatchedMigration } from '../batched-migration.js';\n\nexport default makeBatchedMigration({\n async getParameters() {\n return {\n min: 1n,\n max: 100n,\n batchSize: 10,\n };\n },\n\n async execute(_min: bigint, _max: bigint) {},\n});\n"]}
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ getParameters(): Promise<{
3
+ min: bigint;
4
+ max: bigint;
5
+ batchSize: number;
6
+ }>;
7
+ execute(_min: bigint, _max: bigint): Promise<never>;
8
+ };
9
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { makeBatchedMigration } from '../batched-migration.js';
2
+ export default makeBatchedMigration({
3
+ async getParameters() {
4
+ return {
5
+ min: 2n,
6
+ max: 200n,
7
+ batchSize: 20,
8
+ };
9
+ },
10
+ async execute(_min, _max) {
11
+ throw new Error('Testing failure');
12
+ },
13
+ });
14
+ //# sourceMappingURL=20230406184107_failing_migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20230406184107_failing_migration.js","sourceRoot":"","sources":["../../../src/batched-migrations/fixtures/20230406184107_failing_migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,eAAe,oBAAoB,CAAC;IAClC,KAAK,CAAC,aAAa;QACjB,OAAO;YACL,GAAG,EAAE,EAAE;YACP,GAAG,EAAE,IAAI;YACT,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI;QACtB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { makeBatchedMigration } from '../batched-migration.js';\n\nexport default makeBatchedMigration({\n async getParameters() {\n return {\n min: 2n,\n max: 200n,\n batchSize: 20,\n };\n },\n\n async execute(_min, _max) {\n throw new Error('Testing failure');\n },\n});\n"]}
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const batched_migration_1 = require("../batched-migration");
4
- exports.default = (0, batched_migration_1.makeBatchedMigration)({
1
+ import { makeBatchedMigration } from '../batched-migration.js';
2
+ export default makeBatchedMigration({
5
3
  async getParameters() {
6
4
  return {
7
5
  // Simulates the case where there are no rows to process. A null
@@ -1 +1 @@
1
- {"version":3,"file":"20230407230446_no_rows_migration.js","sourceRoot":"","sources":["../../../src/batched-migrations/fixtures/20230407230446_no_rows_migration.ts"],"names":[],"mappings":";;AAAA,4DAA4D;AAE5D,kBAAe,IAAA,wCAAoB,EAAC;IAClC,KAAK,CAAC,aAAa;QACjB,OAAO;YACL,gEAAgE;YAChE,qDAAqD;YACrD,gCAAgC;YAChC,GAAG,EAAE,IAAI;YACT,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,IAAY,IAAG,CAAC;CAC7C,CAAC,CAAC","sourcesContent":["import { makeBatchedMigration } from '../batched-migration';\n\nexport default makeBatchedMigration({\n async getParameters() {\n return {\n // Simulates the case where there are no rows to process. A null\n // max value is what we would get for some query like\n // `SELECT MAX(id) FROM table;`.\n max: null,\n batchSize: 10,\n };\n },\n\n async execute(_min: bigint, _max: bigint) {},\n});\n"]}
1
+ {"version":3,"file":"20230407230446_no_rows_migration.js","sourceRoot":"","sources":["../../../src/batched-migrations/fixtures/20230407230446_no_rows_migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,eAAe,oBAAoB,CAAC;IAClC,KAAK,CAAC,aAAa;QACjB,OAAO;YACL,gEAAgE;YAChE,qDAAqD;YACrD,gCAAgC;YAChC,GAAG,EAAE,IAAI;YACT,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,IAAY,IAAG,CAAC;CAC7C,CAAC,CAAC","sourcesContent":["import { makeBatchedMigration } from '../batched-migration.js';\n\nexport default makeBatchedMigration({\n async getParameters() {\n return {\n // Simulates the case where there are no rows to process. A null\n // max value is what we would get for some query like\n // `SELECT MAX(id) FROM table;`.\n max: null,\n batchSize: 10,\n };\n },\n\n async execute(_min: bigint, _max: bigint) {},\n});\n"]}
@@ -1,3 +1,3 @@
1
- export { BatchedMigrationRow, BatchedMigrationStatus, makeBatchedMigration, selectAllBatchedMigrations, selectBatchedMigration, selectBatchedMigrationForTimestamp, retryFailedBatchedMigrationJobs, } from './batched-migration';
2
- export { BatchedMigrationJobRow, BatchedMigrationJobStatus, selectRecentJobsWithStatus, } from './batched-migration-job';
3
- export { initBatchedMigrations, startBatchedMigrations, stopBatchedMigrations, enqueueBatchedMigration, finalizeBatchedMigration, } from './batched-migrations-runner';
1
+ export { type BatchedMigrationRow, type BatchedMigrationStatus, makeBatchedMigration, selectAllBatchedMigrations, selectBatchedMigration, selectBatchedMigrationForTimestamp, retryFailedBatchedMigrationJobs, } from './batched-migration.js';
2
+ export { type BatchedMigrationJobRow, type BatchedMigrationJobStatus, selectRecentJobsWithStatus, } from './batched-migration-job.js';
3
+ export { initBatchedMigrations, startBatchedMigrations, stopBatchedMigrations, enqueueBatchedMigration, finalizeBatchedMigration, } from './batched-migrations-runner.js';
@@ -1,18 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.finalizeBatchedMigration = exports.enqueueBatchedMigration = exports.stopBatchedMigrations = exports.startBatchedMigrations = exports.initBatchedMigrations = exports.selectRecentJobsWithStatus = exports.retryFailedBatchedMigrationJobs = exports.selectBatchedMigrationForTimestamp = exports.selectBatchedMigration = exports.selectAllBatchedMigrations = exports.makeBatchedMigration = void 0;
4
- var batched_migration_1 = require("./batched-migration");
5
- Object.defineProperty(exports, "makeBatchedMigration", { enumerable: true, get: function () { return batched_migration_1.makeBatchedMigration; } });
6
- Object.defineProperty(exports, "selectAllBatchedMigrations", { enumerable: true, get: function () { return batched_migration_1.selectAllBatchedMigrations; } });
7
- Object.defineProperty(exports, "selectBatchedMigration", { enumerable: true, get: function () { return batched_migration_1.selectBatchedMigration; } });
8
- Object.defineProperty(exports, "selectBatchedMigrationForTimestamp", { enumerable: true, get: function () { return batched_migration_1.selectBatchedMigrationForTimestamp; } });
9
- Object.defineProperty(exports, "retryFailedBatchedMigrationJobs", { enumerable: true, get: function () { return batched_migration_1.retryFailedBatchedMigrationJobs; } });
10
- var batched_migration_job_1 = require("./batched-migration-job");
11
- Object.defineProperty(exports, "selectRecentJobsWithStatus", { enumerable: true, get: function () { return batched_migration_job_1.selectRecentJobsWithStatus; } });
12
- var batched_migrations_runner_1 = require("./batched-migrations-runner");
13
- Object.defineProperty(exports, "initBatchedMigrations", { enumerable: true, get: function () { return batched_migrations_runner_1.initBatchedMigrations; } });
14
- Object.defineProperty(exports, "startBatchedMigrations", { enumerable: true, get: function () { return batched_migrations_runner_1.startBatchedMigrations; } });
15
- Object.defineProperty(exports, "stopBatchedMigrations", { enumerable: true, get: function () { return batched_migrations_runner_1.stopBatchedMigrations; } });
16
- Object.defineProperty(exports, "enqueueBatchedMigration", { enumerable: true, get: function () { return batched_migrations_runner_1.enqueueBatchedMigration; } });
17
- Object.defineProperty(exports, "finalizeBatchedMigration", { enumerable: true, get: function () { return batched_migrations_runner_1.finalizeBatchedMigration; } });
1
+ export { makeBatchedMigration, selectAllBatchedMigrations, selectBatchedMigration, selectBatchedMigrationForTimestamp, retryFailedBatchedMigrationJobs, } from './batched-migration.js';
2
+ export { selectRecentJobsWithStatus, } from './batched-migration-job.js';
3
+ export { initBatchedMigrations, startBatchedMigrations, stopBatchedMigrations, enqueueBatchedMigration, finalizeBatchedMigration, } from './batched-migrations-runner.js';
18
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/batched-migrations/index.ts"],"names":[],"mappings":";;;AAAA,yDAQ6B;AAL3B,yHAAA,oBAAoB,OAAA;AACpB,+HAAA,0BAA0B,OAAA;AAC1B,2HAAA,sBAAsB,OAAA;AACtB,uIAAA,kCAAkC,OAAA;AAClC,oIAAA,+BAA+B,OAAA;AAEjC,iEAIiC;AAD/B,mIAAA,0BAA0B,OAAA;AAE5B,yEAMqC;AALnC,kIAAA,qBAAqB,OAAA;AACrB,mIAAA,sBAAsB,OAAA;AACtB,kIAAA,qBAAqB,OAAA;AACrB,oIAAA,uBAAuB,OAAA;AACvB,qIAAA,wBAAwB,OAAA","sourcesContent":["export {\n BatchedMigrationRow,\n BatchedMigrationStatus,\n makeBatchedMigration,\n selectAllBatchedMigrations,\n selectBatchedMigration,\n selectBatchedMigrationForTimestamp,\n retryFailedBatchedMigrationJobs,\n} from './batched-migration';\nexport {\n BatchedMigrationJobRow,\n BatchedMigrationJobStatus,\n selectRecentJobsWithStatus,\n} from './batched-migration-job';\nexport {\n initBatchedMigrations,\n startBatchedMigrations,\n stopBatchedMigrations,\n enqueueBatchedMigration,\n finalizeBatchedMigration,\n} from './batched-migrations-runner';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/batched-migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,gCAAgC,CAAC","sourcesContent":["export {\n type BatchedMigrationRow,\n type BatchedMigrationStatus,\n makeBatchedMigration,\n selectAllBatchedMigrations,\n selectBatchedMigration,\n selectBatchedMigrationForTimestamp,\n retryFailedBatchedMigrationJobs,\n} from './batched-migration.js';\nexport {\n type BatchedMigrationJobRow,\n type BatchedMigrationJobStatus,\n selectRecentJobsWithStatus,\n} from './batched-migration-job.js';\nexport {\n initBatchedMigrations,\n startBatchedMigrations,\n stopBatchedMigrations,\n enqueueBatchedMigration,\n finalizeBatchedMigration,\n} from './batched-migrations-runner.js';\n"]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { init } from './migrations';
2
- export { BatchedMigrationRow, BatchedMigrationStatus, BatchedMigrationJobRow, BatchedMigrationJobStatus, makeBatchedMigration, initBatchedMigrations, startBatchedMigrations, stopBatchedMigrations, enqueueBatchedMigration, finalizeBatchedMigration, selectAllBatchedMigrations, selectBatchedMigration, selectBatchedMigrationForTimestamp, selectRecentJobsWithStatus, retryFailedBatchedMigrationJobs, } from './batched-migrations';
1
+ export { init } from './migrations/index.js';
2
+ export { type BatchedMigrationRow, type BatchedMigrationStatus, type BatchedMigrationJobRow, type BatchedMigrationJobStatus, makeBatchedMigration, initBatchedMigrations, startBatchedMigrations, stopBatchedMigrations, enqueueBatchedMigration, finalizeBatchedMigration, selectAllBatchedMigrations, selectBatchedMigration, selectBatchedMigrationForTimestamp, selectRecentJobsWithStatus, retryFailedBatchedMigrationJobs, } from './batched-migrations/index.js';
3
3
  export declare const SCHEMA_MIGRATIONS_PATH: string;
package/dist/index.js CHANGED
@@ -1,23 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SCHEMA_MIGRATIONS_PATH = exports.retryFailedBatchedMigrationJobs = exports.selectRecentJobsWithStatus = exports.selectBatchedMigrationForTimestamp = exports.selectBatchedMigration = exports.selectAllBatchedMigrations = exports.finalizeBatchedMigration = exports.enqueueBatchedMigration = exports.stopBatchedMigrations = exports.startBatchedMigrations = exports.initBatchedMigrations = exports.makeBatchedMigration = exports.init = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- var migrations_1 = require("./migrations");
9
- Object.defineProperty(exports, "init", { enumerable: true, get: function () { return migrations_1.init; } });
10
- var batched_migrations_1 = require("./batched-migrations");
11
- Object.defineProperty(exports, "makeBatchedMigration", { enumerable: true, get: function () { return batched_migrations_1.makeBatchedMigration; } });
12
- Object.defineProperty(exports, "initBatchedMigrations", { enumerable: true, get: function () { return batched_migrations_1.initBatchedMigrations; } });
13
- Object.defineProperty(exports, "startBatchedMigrations", { enumerable: true, get: function () { return batched_migrations_1.startBatchedMigrations; } });
14
- Object.defineProperty(exports, "stopBatchedMigrations", { enumerable: true, get: function () { return batched_migrations_1.stopBatchedMigrations; } });
15
- Object.defineProperty(exports, "enqueueBatchedMigration", { enumerable: true, get: function () { return batched_migrations_1.enqueueBatchedMigration; } });
16
- Object.defineProperty(exports, "finalizeBatchedMigration", { enumerable: true, get: function () { return batched_migrations_1.finalizeBatchedMigration; } });
17
- Object.defineProperty(exports, "selectAllBatchedMigrations", { enumerable: true, get: function () { return batched_migrations_1.selectAllBatchedMigrations; } });
18
- Object.defineProperty(exports, "selectBatchedMigration", { enumerable: true, get: function () { return batched_migrations_1.selectBatchedMigration; } });
19
- Object.defineProperty(exports, "selectBatchedMigrationForTimestamp", { enumerable: true, get: function () { return batched_migrations_1.selectBatchedMigrationForTimestamp; } });
20
- Object.defineProperty(exports, "selectRecentJobsWithStatus", { enumerable: true, get: function () { return batched_migrations_1.selectRecentJobsWithStatus; } });
21
- Object.defineProperty(exports, "retryFailedBatchedMigrationJobs", { enumerable: true, get: function () { return batched_migrations_1.retryFailedBatchedMigrationJobs; } });
22
- exports.SCHEMA_MIGRATIONS_PATH = path_1.default.resolve(__dirname, '..', 'schema-migrations');
1
+ import path from 'path';
2
+ export { init } from './migrations/index.js';
3
+ export { makeBatchedMigration, initBatchedMigrations, startBatchedMigrations, stopBatchedMigrations, enqueueBatchedMigration, finalizeBatchedMigration, selectAllBatchedMigrations, selectBatchedMigration, selectBatchedMigrationForTimestamp, selectRecentJobsWithStatus, retryFailedBatchedMigrationJobs, } from './batched-migrations/index.js';
4
+ export const SCHEMA_MIGRATIONS_PATH = path.resolve(import.meta.dirname, '..', 'schema-migrations');
23
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,2CAAoC;AAA3B,kGAAA,IAAI,OAAA;AAEb,2DAgB8B;AAX5B,0HAAA,oBAAoB,OAAA;AACpB,2HAAA,qBAAqB,OAAA;AACrB,4HAAA,sBAAsB,OAAA;AACtB,2HAAA,qBAAqB,OAAA;AACrB,6HAAA,uBAAuB,OAAA;AACvB,8HAAA,wBAAwB,OAAA;AACxB,gIAAA,0BAA0B,OAAA;AAC1B,4HAAA,sBAAsB,OAAA;AACtB,wIAAA,kCAAkC,OAAA;AAClC,gIAAA,0BAA0B,OAAA;AAC1B,qIAAA,+BAA+B,OAAA;AAGpB,QAAA,sBAAsB,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nexport { init } from './migrations';\n\nexport {\n BatchedMigrationRow,\n BatchedMigrationStatus,\n BatchedMigrationJobRow,\n BatchedMigrationJobStatus,\n makeBatchedMigration,\n initBatchedMigrations,\n startBatchedMigrations,\n stopBatchedMigrations,\n enqueueBatchedMigration,\n finalizeBatchedMigration,\n selectAllBatchedMigrations,\n selectBatchedMigration,\n selectBatchedMigrationForTimestamp,\n selectRecentJobsWithStatus,\n retryFailedBatchedMigrationJobs,\n} from './batched-migrations';\n\nexport const SCHEMA_MIGRATIONS_PATH = path.resolve(__dirname, '..', 'schema-migrations');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAKL,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,kCAAkC,EAClC,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AAEvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nexport { init } from './migrations/index.js';\n\nexport {\n type BatchedMigrationRow,\n type BatchedMigrationStatus,\n type BatchedMigrationJobRow,\n type BatchedMigrationJobStatus,\n makeBatchedMigration,\n initBatchedMigrations,\n startBatchedMigrations,\n stopBatchedMigrations,\n enqueueBatchedMigration,\n finalizeBatchedMigration,\n selectAllBatchedMigrations,\n selectBatchedMigration,\n selectBatchedMigrationForTimestamp,\n selectRecentJobsWithStatus,\n retryFailedBatchedMigrationJobs,\n} from './batched-migrations/index.js';\n\nexport const SCHEMA_MIGRATIONS_PATH = path.resolve(import.meta.dirname, '..', 'schema-migrations');\n"]}
@@ -1,10 +1,4 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseAnnotations = exports.sortMigrationFiles = exports.readAndValidateMigrationsFromDirectories = exports.readAndValidateMigrationsFromDirectory = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
1
+ import fs from 'fs-extra';
8
2
  /**
9
3
  * Timestamp prefixes will be of the form `YYYYMMDDHHMMSS`, which will have 14 digits.
10
4
  * If this code is still around in the year 10000... good luck.
@@ -21,8 +15,8 @@ const MIGRATION_FILENAME_REGEX = /^([0-9]{14})_.+\.[a-z]+/;
21
15
  */
22
16
  const ANNOTATION_PREFIX = '-- prairielearn:migrations';
23
17
  const ALLOWED_ANNOTATIONS = new Set(['NO TRANSACTION']);
24
- async function readAndValidateMigrationsFromDirectory(dir, extensions) {
25
- const migrationFiles = (await fs_extra_1.default.readdir(dir)).filter((m) => extensions.some((e) => m.endsWith(e)));
18
+ export async function readAndValidateMigrationsFromDirectory(dir, extensions) {
19
+ const migrationFiles = (await fs.readdir(dir)).filter((m) => extensions.some((e) => m.endsWith(e)));
26
20
  const migrations = migrationFiles.map((mf) => {
27
21
  const match = mf.match(MIGRATION_FILENAME_REGEX);
28
22
  if (!match) {
@@ -52,8 +46,7 @@ async function readAndValidateMigrationsFromDirectory(dir, extensions) {
52
46
  }
53
47
  return migrations;
54
48
  }
55
- exports.readAndValidateMigrationsFromDirectory = readAndValidateMigrationsFromDirectory;
56
- async function readAndValidateMigrationsFromDirectories(directories, extensions) {
49
+ export async function readAndValidateMigrationsFromDirectories(directories, extensions) {
57
50
  const allMigrations = [];
58
51
  for (const directory of directories) {
59
52
  const migrations = await readAndValidateMigrationsFromDirectory(directory, extensions);
@@ -61,14 +54,12 @@ async function readAndValidateMigrationsFromDirectories(directories, extensions)
61
54
  }
62
55
  return allMigrations;
63
56
  }
64
- exports.readAndValidateMigrationsFromDirectories = readAndValidateMigrationsFromDirectories;
65
- function sortMigrationFiles(migrationFiles) {
57
+ export function sortMigrationFiles(migrationFiles) {
66
58
  return migrationFiles.sort((a, b) => {
67
59
  return a.timestamp.localeCompare(b.timestamp);
68
60
  });
69
61
  }
70
- exports.sortMigrationFiles = sortMigrationFiles;
71
- function parseAnnotations(contents) {
62
+ export function parseAnnotations(contents) {
72
63
  const lines = contents.split('\n');
73
64
  const annotations = new Set();
74
65
  lines.forEach((line) => {
@@ -82,5 +73,4 @@ function parseAnnotations(contents) {
82
73
  });
83
74
  return annotations;
84
75
  }
85
- exports.parseAnnotations = parseAnnotations;
86
76
  //# sourceMappingURL=load-migrations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-migrations.js","sourceRoot":"","sources":["../src/load-migrations.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAE1B;;;GAGG;AACH,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AACvD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAQjD,KAAK,UAAU,sCAAsC,CAC1D,GAAW,EACX,UAAoB;IAEpB,MAAM,cAAc,GAAG,CAAC,MAAM,kBAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1D,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CACtC,CAAC;IAEF,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAEjD,I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gB,kBAAkB,CAAC,cAA+B;IAChE,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAClC,OAAO,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,gDAIC;AAED,SAAgB,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACvC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;YAC/D,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,uBAAuB,UAAU,EAAE,CAAC,CAAC;YACvD,CAAC;YACD,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC;AAfD,4CAeC","sourcesContent":["import fs from 'fs-extra';\n\n/**\n * Timestamp prefixes will be of the form `YYYYMMDDHHMMSS`, which will have 14 digits.\n * If this code is still around in the year 10000... good luck.\n */\nconst MIGRATION_FILENAME_REGEX = /^([0-9]{14})_.+\\.[a-z]+/;\n\n/**\n * Annotations are expressed via the following:\n *\n * -- prairielearn:migrations NO TRANSACTION\n *\n * Currently, `NO TRANSACTION` is the only supported annotation. This will run\n * the migration without a transaction. This is useful for migrations that use\n * features that can't be run in transactions, such as `CREATE INDEX CONCURRENTLY`.\n */\nconst ANNOTATION_PREFIX = '-- prairielearn:migrations';\nconst ALLOWED_ANNOTATIONS = new Set(['NO TRANSACTION']);\n\nexport interface MigrationFile {\n directory: string;\n filename: string;\n timestamp: string;\n}\n\nexport async function readAndValidateMigrationsFromDirectory(\n dir: string,\n extensions: string[],\n): Promise<MigrationFile[]> {\n const migrationFiles = (await fs.readdir(dir)).filter((m) =>\n extensions.some((e) => m.endsWith(e)),\n );\n\n const migrations = migrationFiles.map((mf) => {\n const match = mf.match(MIGRATION_FILENAME_REGEX);\n\n if (!match) {\n throw new Error(`Invalid migration filename: ${mf}`);\n }\n\n const timestamp = match[1] ?? null;\n\n if (timestamp === null) {\n throw new Error(`Migration ${mf} does not have a timestamp`);\n }\n\n return {\n directory: dir,\n filename: mf,\n timestamp,\n };\n });\n\n // First pass: validate that all migrations have a unique timestamp prefix.\n // This will avoid data loss and conflicts in unexpected scenarios.\n const seenTimestamps = new Set();\n for (const migration of migrations) {\n const { filename, timestamp } = migration;\n\n if (timestamp !== null) {\n if (seenTimestamps.has(timestamp)) {\n throw new Error(`Duplicate migration timestamp: ${timestamp} (${filename})`);\n }\n seenTimestamps.add(timestamp);\n }\n }\n\n return migrations;\n}\n\nexport async function readAndValidateMigrationsFromDirectories(\n directories: string[],\n extensions: string[],\n): Promise<MigrationFile[]> {\n const allMigrations: MigrationFile[] = [];\n for (const directory of directories) {\n const migrations = await readAndValidateMigrationsFromDirectory(directory, extensions);\n allMigrations.push(...migrations);\n }\n return allMigrations;\n}\n\nexport function sortMigrationFiles(migrationFiles: MigrationFile[]): MigrationFile[] {\n return migrationFiles.sort((a, b) => {\n return a.timestamp.localeCompare(b.timestamp);\n });\n}\n\nexport function parseAnnotations(contents: string): Set<string> {\n const lines = contents.split('\\n');\n const annotations = new Set<string>();\n\n lines.forEach((line) => {\n if (line.startsWith(ANNOTATION_PREFIX)) {\n const annotation = line.slice(ANNOTATION_PREFIX.length).trim();\n if (!ALLOWED_ANNOTATIONS.has(annotation)) {\n throw new Error(`Invalid annotation: ${annotation}`);\n }\n annotations.add(annotation);\n }\n });\n\n return annotations;\n}\n"]}
1
+ {"version":3,"file":"load-migrations.js","sourceRoot":"","sources":["../src/load-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B;;;GAGG;AACH,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AACvD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAQxD,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,GAAW,EACX,UAAoB;IAEpB,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1D,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CACtC,CAAC;IAEF,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QAEnC,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,aAAa,EAAE,4BAA4B,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO;YACL,SAAS,EAAE,GAAG;YACd,QAAQ,EAAE,EAAE;YACZ,SAAS;SACV,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,2EAA2E;IAC3E,mEAAmE;IACnE,MAAM,c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AU,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACvC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;YAC/D,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,uBAAuB,UAAU,EAAE,CAAC,CAAC;YACvD,CAAC;YACD,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import fs from 'fs-extra';\n\n/**\n * Timestamp prefixes will be of the form `YYYYMMDDHHMMSS`, which will have 14 digits.\n * If this code is still around in the year 10000... good luck.\n */\nconst MIGRATION_FILENAME_REGEX = /^([0-9]{14})_.+\\.[a-z]+/;\n\n/**\n * Annotations are expressed via the following:\n *\n * -- prairielearn:migrations NO TRANSACTION\n *\n * Currently, `NO TRANSACTION` is the only supported annotation. This will run\n * the migration without a transaction. This is useful for migrations that use\n * features that can't be run in transactions, such as `CREATE INDEX CONCURRENTLY`.\n */\nconst ANNOTATION_PREFIX = '-- prairielearn:migrations';\nconst ALLOWED_ANNOTATIONS = new Set(['NO TRANSACTION']);\n\nexport interface MigrationFile {\n directory: string;\n filename: string;\n timestamp: string;\n}\n\nexport async function readAndValidateMigrationsFromDirectory(\n dir: string,\n extensions: string[],\n): Promise<MigrationFile[]> {\n const migrationFiles = (await fs.readdir(dir)).filter((m) =>\n extensions.some((e) => m.endsWith(e)),\n );\n\n const migrations = migrationFiles.map((mf) => {\n const match = mf.match(MIGRATION_FILENAME_REGEX);\n\n if (!match) {\n throw new Error(`Invalid migration filename: ${mf}`);\n }\n\n const timestamp = match[1] ?? null;\n\n if (timestamp === null) {\n throw new Error(`Migration ${mf} does not have a timestamp`);\n }\n\n return {\n directory: dir,\n filename: mf,\n timestamp,\n };\n });\n\n // First pass: validate that all migrations have a unique timestamp prefix.\n // This will avoid data loss and conflicts in unexpected scenarios.\n const seenTimestamps = new Set();\n for (const migration of migrations) {\n const { filename, timestamp } = migration;\n\n if (timestamp !== null) {\n if (seenTimestamps.has(timestamp)) {\n throw new Error(`Duplicate migration timestamp: ${timestamp} (${filename})`);\n }\n seenTimestamps.add(timestamp);\n }\n }\n\n return migrations;\n}\n\nexport async function readAndValidateMigrationsFromDirectories(\n directories: string[],\n extensions: string[],\n): Promise<MigrationFile[]> {\n const allMigrations: MigrationFile[] = [];\n for (const directory of directories) {\n const migrations = await readAndValidateMigrationsFromDirectory(directory, extensions);\n allMigrations.push(...migrations);\n }\n return allMigrations;\n}\n\nexport function sortMigrationFiles(migrationFiles: MigrationFile[]): MigrationFile[] {\n return migrationFiles.sort((a, b) => {\n return a.timestamp.localeCompare(b.timestamp);\n });\n}\n\nexport function parseAnnotations(contents: string): Set<string> {\n const lines = contents.split('\\n');\n const annotations = new Set<string>();\n\n lines.forEach((line) => {\n if (line.startsWith(ANNOTATION_PREFIX)) {\n const annotation = line.slice(ANNOTATION_PREFIX.length).trim();\n if (!ALLOWED_ANNOTATIONS.has(annotation)) {\n throw new Error(`Invalid annotation: ${annotation}`);\n }\n annotations.add(annotation);\n }\n });\n\n return annotations;\n}\n"]}
@@ -1,42 +1,14 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const chai_1 = __importStar(require("chai"));
30
- const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
31
- const path_1 = __importDefault(require("path"));
32
- const tmp_promise_1 = __importDefault(require("tmp-promise"));
33
- const fs_extra_1 = __importDefault(require("fs-extra"));
34
- const load_migrations_1 = require("./load-migrations");
35
- chai_1.default.use(chai_as_promised_1.default);
1
+ import path from 'path';
2
+ import { use as chaiUse, assert } from 'chai';
3
+ import chaiAsPromised from 'chai-as-promised';
4
+ import fs from 'fs-extra';
5
+ import tmp from 'tmp-promise';
6
+ import { parseAnnotations, readAndValidateMigrationsFromDirectory, sortMigrationFiles, } from './load-migrations.js';
7
+ chaiUse(chaiAsPromised);
36
8
  async function withMigrationFiles(files, fn) {
37
- await tmp_promise_1.default.withDir(async function (tmpDir) {
9
+ await tmp.withDir(async function (tmpDir) {
38
10
  for (const file of files) {
39
- await fs_extra_1.default.writeFile(path_1.default.join(tmpDir.path, file), '');
11
+ await fs.writeFile(path.join(tmpDir.path, file), '');
40
12
  }
41
13
  await fn(tmpDir.path);
42
14
  }, { unsafeCleanup: true });
@@ -45,18 +17,18 @@ describe('load-migrations', () => {
45
17
  describe('readAndValidateMigrationsFromDirectory', () => {
46
18
  it('handles migrations without a timestamp', async () => {
47
19
  await withMigrationFiles(['001_testing.sql'], async (tmpDir) => {
48
- await chai_1.assert.isRejected((0, load_migrations_1.readAndValidateMigrationsFromDirectory)(tmpDir, ['.sql']), 'Invalid migration filename: 001_testing.sql');
20
+ await assert.isRejected(readAndValidateMigrationsFromDirectory(tmpDir, ['.sql']), 'Invalid migration filename: 001_testing.sql');
49
21
  });
50
22
  });
51
23
  it('handles duplicate timestamps', async () => {
52
24
  await withMigrationFiles(['20220101010101_testing.sql', '20220101010101_testing_again.sql'], async (tmpDir) => {
53
- await chai_1.assert.isRejected((0, load_migrations_1.readAndValidateMigrationsFromDirectory)(tmpDir, ['.sql']), 'Duplicate migration timestamp');
25
+ await assert.isRejected(readAndValidateMigrationsFromDirectory(tmpDir, ['.sql']), 'Duplicate migration timestamp');
54
26
  });
55
27
  });
56
28
  });
57
29
  describe('sortMigrationFiles', () => {
58
30
  it('sorts by timestamp', () => {
59
- chai_1.assert.deepEqual((0, load_migrations_1.sortMigrationFiles)([
31
+ assert.deepEqual(sortMigrationFiles([
60
32
  {
61
33
  directory: 'migrations',
62
34
  filename: '20220101010103_testing_3.sql',
@@ -93,12 +65,12 @@ describe('load-migrations', () => {
93
65
  });
94
66
  describe('parseAnnotations', () => {
95
67
  it('parses a NO TRANSACTION annotation', () => {
96
- const annotations = (0, load_migrations_1.parseAnnotations)('-- prairielearn:migrations NO TRANSACTION');
97
- chai_1.assert.deepEqual(annotations, new Set(['NO TRANSACTION']));
68
+ const annotations = parseAnnotations('-- prairielearn:migrations NO TRANSACTION');
69
+ assert.deepEqual(annotations, new Set(['NO TRANSACTION']));
98
70
  });
99
71
  it('throws an error for an invalid annotation', () => {
100
- chai_1.assert.throws(() => {
101
- (0, load_migrations_1.parseAnnotations)('-- prairielearn:migrations INVALID');
72
+ assert.throws(() => {
73
+ parseAnnotations('-- prairielearn:migrations INVALID');
102
74
  });
103
75
  });
104
76
  });
@@ -1 +1 @@
1
- {"version":3,"file":"load-migrations.test.js","sourceRoot":"","sources":["../src/load-migrations.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAoC;AACpC,wEAA8C;AAC9C,gDAAwB;AACxB,8DAA8B;AAC9B,wDAA0B;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IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import chai, { assert } from 'chai';\nimport chaiAsPromised from 'chai-as-promised';\nimport path from 'path';\nimport tmp from 'tmp-promise';\nimport fs from 'fs-extra';\n\nimport {\n parseAnnotations,\n readAndValidateMigrationsFromDirectory,\n sortMigrationFiles,\n} from './load-migrations';\n\nchai.use(chaiAsPromised);\n\nasync function withMigrationFiles(files: string[], fn: (tmpDir: string) => Promise<void>) {\n await tmp.withDir(\n async function (tmpDir) {\n for (const file of files) {\n await fs.writeFile(path.join(tmpDir.path, file), '');\n }\n await fn(tmpDir.path);\n },\n { unsafeCleanup: true },\n );\n}\n\ndescribe('load-migrations', () => {\n describe('readAndValidateMigrationsFromDirectory', () => {\n it('handles migrations without a timestamp', async () => {\n await withMigrationFiles(['001_testing.sql'], async (tmpDir) => {\n await assert.isRejected(\n readAndValidateMigrationsFromDirectory(tmpDir, ['.sql']),\n 'Invalid migration filename: 001_testing.sql',\n );\n });\n });\n\n it('handles duplicate timestamps', async () => {\n await withMigrationFiles(\n ['20220101010101_testing.sql', '20220101010101_testing_again.sql'],\n async (tmpDir) => {\n await assert.isRejected(\n readAndValidateMigrationsFromDirectory(tmpDir, ['.sql']),\n 'Duplicate migration timestamp',\n );\n },\n );\n });\n });\n\n describe('sortMigrationFiles', () => {\n it('sorts by timestamp', () => {\n assert.deepEqual(\n sortMigrationFiles([\n {\n directory: 'migrations',\n filename: '20220101010103_testing_3.sql',\n timestamp: '20220101010103',\n },\n {\n directory: 'migrations',\n filename: '20220101010101_testing_1.sql',\n timestamp: '20220101010101',\n },\n {\n directory: 'migrations',\n filename: '20220101010102_testing_2.sql',\n timestamp: '20220101010102',\n },\n ]),\n [\n {\n directory: 'migrations',\n filename: '20220101010101_testing_1.sql',\n timestamp: '20220101010101',\n },\n {\n directory: 'migrations',\n filename: '20220101010102_testing_2.sql',\n timestamp: '20220101010102',\n },\n {\n directory: 'migrations',\n filename: '20220101010103_testing_3.sql',\n timestamp: '20220101010103',\n },\n ],\n );\n });\n });\n\n describe('parseAnnotations', () => {\n it('parses a NO TRANSACTION annotation', () => {\n const annotations = parseAnnotations('-- prairielearn:migrations NO TRANSACTION');\n assert.deepEqual(annotations, new Set(['NO TRANSACTION']));\n });\n\n it('throws an error for an invalid annotation', () => {\n assert.throws(() => {\n parseAnnotations('-- prairielearn:migrations INVALID');\n });\n });\n });\n});\n"]}
1
+ {"version":3,"file":"load-migrations.test.js","sourceRoot":"","sources":["../src/load-migrations.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,GAAG,MAAM,aAAa,CAAC;AAE9B,OAAO,EACL,gBAAgB,EAChB,sCAAsC,EACtC,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,CAAC,cAAc,CAAC,CAAC;AAExB,KAAK,UAAU,kBAAkB,CAAC,KAAe,EAAE,EAAqC;IACtF,MAAM,GAAG,CAAC,OAAO,CACf,KAAK,WAAW,MAAM;QACpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,EACD,EAAE,aAAa,EAAE,IAAI,EAAE,CACxB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;QACtD,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;Y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Y;oBACvB,QAAQ,EAAE,8BAA8B;oBACxC,SAAS,EAAE,gBAAgB;iBAC5B;aACF,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC5C,MAAM,WAAW,GAAG,gBAAgB,CAAC,2CAA2C,CAAC,CAAC;YAClF,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;YACnD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;gBACjB,gBAAgB,CAAC,oCAAoC,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nimport { use as chaiUse, assert } from 'chai';\nimport chaiAsPromised from 'chai-as-promised';\nimport fs from 'fs-extra';\nimport tmp from 'tmp-promise';\n\nimport {\n parseAnnotations,\n readAndValidateMigrationsFromDirectory,\n sortMigrationFiles,\n} from './load-migrations.js';\n\nchaiUse(chaiAsPromised);\n\nasync function withMigrationFiles(files: string[], fn: (tmpDir: string) => Promise<void>) {\n await tmp.withDir(\n async function (tmpDir) {\n for (const file of files) {\n await fs.writeFile(path.join(tmpDir.path, file), '');\n }\n await fn(tmpDir.path);\n },\n { unsafeCleanup: true },\n );\n}\n\ndescribe('load-migrations', () => {\n describe('readAndValidateMigrationsFromDirectory', () => {\n it('handles migrations without a timestamp', async () => {\n await withMigrationFiles(['001_testing.sql'], async (tmpDir) => {\n await assert.isRejected(\n readAndValidateMigrationsFromDirectory(tmpDir, ['.sql']),\n 'Invalid migration filename: 001_testing.sql',\n );\n });\n });\n\n it('handles duplicate timestamps', async () => {\n await withMigrationFiles(\n ['20220101010101_testing.sql', '20220101010101_testing_again.sql'],\n async (tmpDir) => {\n await assert.isRejected(\n readAndValidateMigrationsFromDirectory(tmpDir, ['.sql']),\n 'Duplicate migration timestamp',\n );\n },\n );\n });\n });\n\n describe('sortMigrationFiles', () => {\n it('sorts by timestamp', () => {\n assert.deepEqual(\n sortMigrationFiles([\n {\n directory: 'migrations',\n filename: '20220101010103_testing_3.sql',\n timestamp: '20220101010103',\n },\n {\n directory: 'migrations',\n filename: '20220101010101_testing_1.sql',\n timestamp: '20220101010101',\n },\n {\n directory: 'migrations',\n filename: '20220101010102_testing_2.sql',\n timestamp: '20220101010102',\n },\n ]),\n [\n {\n directory: 'migrations',\n filename: '20220101010101_testing_1.sql',\n timestamp: '20220101010101',\n },\n {\n directory: 'migrations',\n filename: '20220101010102_testing_2.sql',\n timestamp: '20220101010102',\n },\n {\n directory: 'migrations',\n filename: '20220101010103_testing_3.sql',\n timestamp: '20220101010103',\n },\n ],\n );\n });\n });\n\n describe('parseAnnotations', () => {\n it('parses a NO TRANSACTION annotation', () => {\n const annotations = parseAnnotations('-- prairielearn:migrations NO TRANSACTION');\n assert.deepEqual(annotations, new Set(['NO TRANSACTION']));\n });\n\n it('throws an error for an invalid annotation', () => {\n assert.throws(() => {\n parseAnnotations('-- prairielearn:migrations INVALID');\n });\n });\n });\n});\n"]}
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const postgres_1 = require("@prairielearn/postgres");
4
- async function migrate() {
5
- await (0, postgres_1.queryAsync)("INSERT INTO users (name) VALUES ('Test User')", {});
1
+ import { queryAsync } from '@prairielearn/postgres';
2
+ export default async function migrate() {
3
+ await queryAsync("INSERT INTO users (name) VALUES ('Test User')", {});
6
4
  }
7
- exports.default = migrate;
8
5
  //# sourceMappingURL=20230407210430_insert_user.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"20230407210430_insert_user.js","sourceRoot":"","sources":["../../../src/migrations/fixtures/20230407210430_insert_user.ts"],"names":[],"mappings":";;AAAA,qDAAoD;AAErC,KAAK,UAAU,OAAO;IACnC,MAAM,IAAA,qBAAU,EAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC;AAFD,0BAEC","sourcesContent":["import { queryAsync } from '@prairielearn/postgres';\n\nexport default async function migrate() {\n await queryAsync(\"INSERT INTO users (name) VALUES ('Test User')\", {});\n}\n"]}
1
+ {"version":3,"file":"20230407210430_insert_user.js","sourceRoot":"","sources":["../../../src/migrations/fixtures/20230407210430_insert_user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,OAAO;IACnC,MAAM,UAAU,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import { queryAsync } from '@prairielearn/postgres';\n\nexport default async function migrate() {\n await queryAsync(\"INSERT INTO users (name) VALUES ('Test User')\", {});\n}\n"]}
@@ -1 +1 @@
1
- export { init } from './migrations';
1
+ export { init } from './migrations.js';
@@ -1,6 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.init = void 0;
4
- var migrations_1 = require("./migrations");
5
- Object.defineProperty(exports, "init", { enumerable: true, get: function () { return migrations_1.init; } });
1
+ export { init } from './migrations.js';
6
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;AAAA,2CAAoC;AAA3B,kGAAA,IAAI,OAAA","sourcesContent":["export { init } from './migrations';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { init } from './migrations.js';\n"]}
@@ -1,4 +1,4 @@
1
- import { MigrationFile } from '../load-migrations';
1
+ import { MigrationFile } from '../load-migrations.js';
2
2
  export declare function init(directories: string | string[], project: string): Promise<void>;
3
3
  export declare function getMigrationsToExecute(migrationFiles: MigrationFile[], executedMigrations: {
4
4
  timestamp: string | null;