@prisma/migrate 6.6.0-dev.27 → 6.6.0-dev.29

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 (48) hide show
  1. package/dist/Migrate.js +5 -3
  2. package/dist/SchemaEngine.js +3 -3
  3. package/dist/bin.js +29 -28
  4. package/dist/chunk-23DZXSTI.js +62 -0
  5. package/dist/{chunk-VVP3QZ7Q.js → chunk-5Q5BJS5B.js} +63 -20
  6. package/dist/{chunk-YBNDKPPO.js → chunk-63ZT25OL.js} +12 -10
  7. package/dist/{chunk-DJMFXNR4.js → chunk-74LUB4XX.js} +56 -57
  8. package/dist/{chunk-IWC5MH4R.js → chunk-ABQZ5J74.js} +5 -5
  9. package/dist/{chunk-324Z6HS7.js → chunk-AM7BRZFD.js} +12 -10
  10. package/dist/{chunk-HJFSTAJX.js → chunk-BUAYZ4KA.js} +12 -10
  11. package/dist/{chunk-K43RXWQY.js → chunk-GHZAN2PG.js} +3 -9
  12. package/dist/{chunk-ZGR2WQ62.js → chunk-HPT54KSO.js} +9 -7
  13. package/dist/{chunk-KMHFSDY6.js → chunk-HQJ7FIWN.js} +14 -12
  14. package/dist/{chunk-GPNGRJAR.js → chunk-IRYXRMQC.js} +12 -10
  15. package/dist/{chunk-FBWTUBJC.js → chunk-LAEOX7QH.js} +12 -8
  16. package/dist/{chunk-MKS2ZJJ5.js → chunk-MTJFLQI4.js} +5 -5
  17. package/dist/{chunk-NJYZPNB4.js → chunk-SCH55BRJ.js} +36 -37
  18. package/dist/{chunk-DQMYH4YE.js → chunk-U6ZL4ORM.js} +10 -9
  19. package/dist/chunk-V6PVGSDJ.js +76 -0
  20. package/dist/{chunk-RI5NUPOB.js → chunk-WX6S3QMO.js} +11 -10
  21. package/dist/{chunk-BURHAP6O.js → chunk-ZCR4PTT3.js} +13 -18
  22. package/dist/commands/DbDrop.js +3 -4
  23. package/dist/commands/DbExecute.js +6 -4
  24. package/dist/commands/DbPull.js +6 -6
  25. package/dist/commands/DbPush.js +7 -6
  26. package/dist/commands/MigrateDeploy.js +7 -6
  27. package/dist/commands/MigrateDev.js +7 -6
  28. package/dist/commands/MigrateDiff.js +7 -5
  29. package/dist/commands/MigrateReset.js +7 -6
  30. package/dist/commands/MigrateResolve.js +7 -6
  31. package/dist/commands/MigrateStatus.js +7 -6
  32. package/dist/index.js +35 -33
  33. package/dist/internals/src/cli/schemaContext.d.ts +43 -0
  34. package/dist/internals/src/index.d.ts +1 -0
  35. package/dist/internals/src/migrateTypes.d.ts +63 -0
  36. package/dist/migrate/src/Migrate.d.ts +3 -1
  37. package/dist/migrate/src/SchemaEngine.d.ts +0 -4
  38. package/dist/migrate/src/types.d.ts +13 -10
  39. package/dist/migrate/src/utils/createMigration.d.ts +21 -0
  40. package/dist/migrate/src/utils/ensureDatabaseExists.d.ts +4 -6
  41. package/dist/migrate/src/utils/listMigrations.d.ts +9 -0
  42. package/dist/utils/createMigration.js +27 -0
  43. package/dist/utils/ensureDatabaseExists.js +6 -6
  44. package/dist/utils/getDatabaseVersionSafe.js +3 -3
  45. package/dist/utils/introspectSql.js +3 -3
  46. package/dist/utils/listMigrations.js +25 -0
  47. package/dist/utils/setupMSSQL.js +1 -1
  48. package/package.json +7 -7
@@ -1,4 +1,67 @@
1
1
  export declare namespace MigrateTypes {
2
+ type MigrationDirectory = {
3
+ /**
4
+ * Relative path to a migration directory from `baseDir`.
5
+ * E.g., `./20201117144659_test`.
6
+ */
7
+ path: string;
8
+ /**
9
+ * Description of the migration file in the directory.
10
+ */
11
+ migrationFile: {
12
+ /**
13
+ * Relative path to the migration file from `path`.
14
+ */
15
+ path: 'migration.sql';
16
+ /**
17
+ * Content of the migration file.
18
+ * E.g.,
19
+ * ```sql
20
+ * -- CreateTable
21
+ * CREATE TABLE "Blog" (
22
+ * "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
23
+ *
24
+ * "viewCount20" INTEGER NOT NULL
25
+ * );
26
+ * ```
27
+ */
28
+ content: Tagged<'ok', {
29
+ value: string;
30
+ }> | Tagged<'error', {
31
+ value: Error;
32
+ }>;
33
+ };
34
+ };
35
+ type MigrationLockfile = {
36
+ /**
37
+ * Relative path to the lockfile from `baseDir`.
38
+ */
39
+ path: 'migration_lock.toml';
40
+ /**
41
+ * Content of the lockfile, if it exists.
42
+ * E.g.,
43
+ * ```toml
44
+ * # Please do not edit this file manually
45
+ * provider = "sqlite"
46
+ * ```
47
+ */
48
+ content: string | null;
49
+ };
50
+ type MigrationList = {
51
+ /**
52
+ * Absolute path to the base directory of Prisma migrations.
53
+ * E.g., `/usr/src/app/prisma/migrations`.
54
+ */
55
+ baseDir: string;
56
+ /**
57
+ * Description of the lockfile, which may or may not exist.
58
+ */
59
+ lockfile: MigrationLockfile;
60
+ /**
61
+ * Description of the migration directories.
62
+ */
63
+ migrationDirectories: Array<MigrationDirectory>;
64
+ };
2
65
  type SchemaContainer = {
3
66
  path: string;
4
67
  content: string;
@@ -10,7 +10,9 @@ export declare class Migrate {
10
10
  stop(): void;
11
11
  getPrismaSchema(): Promise<GetSchemaResult>;
12
12
  reset(): Promise<void>;
13
- createMigration(params: EngineArgs.CreateMigrationInput): Promise<EngineResults.CreateMigrationOutput>;
13
+ createMigration(params: Omit<EngineArgs.CreateMigrationInput, 'migrationsList'>): Promise<{
14
+ generatedMigrationName: string | undefined;
15
+ }>;
14
16
  diagnoseMigrationHistory({ optInToShadowDatabase, }: {
15
17
  optInToShadowDatabase: boolean;
16
18
  }): Promise<EngineResults.DiagnoseMigrationHistoryOutput>;
@@ -94,10 +94,6 @@ export declare class SchemaEngine {
94
94
  * By default, we output a human-readable diff. If you want an executable script, pass the "script": true param.
95
95
  */
96
96
  migrateDiff(args: EngineArgs.MigrateDiffInput): Promise<EngineResults.MigrateDiffOutput>;
97
- /**
98
- * List the names of the migrations in the migrations directory.
99
- */
100
- listMigrationDirectories(args: EngineArgs.ListMigrationDirectoriesInput): Promise<EngineResults.ListMigrationDirectoriesOutput>;
101
97
  /**
102
98
  * Mark a migration as applied in the migrations table.
103
99
  * There are two possible outcomes:
@@ -1,4 +1,4 @@
1
- import type { SqlQueryOutput } from '@prisma/generator-helper';
1
+ import type { ActiveConnectorType, SqlQueryOutput } from '@prisma/generator-helper';
2
2
  import type { MigrateTypes } from '@prisma/internals';
3
3
  import type { IntrospectionViewDefinition } from './views/handleViewsIO';
4
4
  export interface RpcRequestResponse {
@@ -69,13 +69,13 @@ export declare namespace EngineArgs {
69
69
  * These RPCs need a sourceConfig, therefore a db connection to function
70
70
  */
71
71
  export interface ApplyMigrationsInput {
72
- migrationsDirectoryPath: string;
72
+ migrationsList: MigrateTypes.MigrationList;
73
73
  }
74
74
  export interface CreateMigrationInput {
75
- migrationsDirectoryPath: string;
75
+ migrationsList: MigrateTypes.MigrationList;
76
76
  schema: MigrateTypes.SchemasContainer;
77
77
  draft: boolean;
78
- migrationName?: string;
78
+ migrationName: string;
79
79
  }
80
80
  export interface CreateDatabaseInput {
81
81
  datasource: MigrateTypes.DatasourceParam;
@@ -110,24 +110,24 @@ export declare namespace EngineArgs {
110
110
  views: IntrospectionViewDefinition[] | null;
111
111
  }
112
112
  export interface DevDiagnosticInput {
113
- migrationsDirectoryPath: string;
113
+ migrationsList: MigrateTypes.MigrationList;
114
114
  }
115
115
  export interface DiagnoseMigrationHistoryInput {
116
- migrationsDirectoryPath: string;
116
+ migrationsList: MigrateTypes.MigrationList;
117
117
  optInToShadowDatabase: boolean;
118
118
  }
119
119
  export interface EnsureConnectionValidityInput {
120
120
  datasource: MigrateTypes.DatasourceParam;
121
121
  }
122
122
  export interface EvaluateDataLossInput {
123
- migrationsDirectoryPath: string;
123
+ migrationsList: MigrateTypes.MigrationList;
124
124
  schema: MigrateTypes.SchemasContainer;
125
125
  }
126
126
  export interface ListMigrationDirectoriesInput {
127
127
  migrationsDirectoryPath: string;
128
128
  }
129
129
  export interface MarkMigrationAppliedInput {
130
- migrationsDirectoryPath: string;
130
+ migrationsList: MigrateTypes.MigrationList;
131
131
  migrationName: string;
132
132
  }
133
133
  export interface MarkMigrationRolledBackInput {
@@ -141,7 +141,7 @@ export declare namespace EngineArgs {
141
141
  type MigrateDiffTargetSchemaDatasource = MigrateTypes.Tagged<'schemaDatasource', MigrateTypes.SchemasWithConfigDir>;
142
142
  type MigrateDiffTargetMigrations = {
143
143
  tag: 'migrations';
144
- path: string;
144
+ migrationsList: MigrateTypes.MigrationList;
145
145
  };
146
146
  export type MigrateDiffTarget = MigrateDiffTargetUrl | MigrateDiffTargetEmpty | MigrateDiffTargetSchemaDatamodel | MigrateDiffTargetSchemaDatasource | MigrateDiffTargetMigrations;
147
147
  export interface MigrateDiffInput {
@@ -173,7 +173,10 @@ export declare namespace EngineResults {
173
173
  database_name: string;
174
174
  }
175
175
  interface CreateMigrationOutput {
176
- generatedMigrationName: string | null;
176
+ connectorType: ActiveConnectorType;
177
+ generatedMigrationName: string;
178
+ migrationScript: string | null;
179
+ extension: string;
177
180
  }
178
181
  interface DbExecuteOutput {
179
182
  }
@@ -0,0 +1,21 @@
1
+ import type { ActiveConnectorType } from '@prisma/generator-helper';
2
+ import type { MigrateTypes } from '@prisma/internals';
3
+ type CreateMigrationInput = {
4
+ baseDir: string;
5
+ generatedMigrationName: string;
6
+ };
7
+ export declare function createMigration({ baseDir, generatedMigrationName }: CreateMigrationInput): Promise<string>;
8
+ type WriteMigrationScriptInput = {
9
+ baseDir: string;
10
+ migrationName: string;
11
+ extension: string;
12
+ script: string;
13
+ };
14
+ export declare function writeMigrationScript({ baseDir, extension, migrationName, script, }: WriteMigrationScriptInput): Promise<void>;
15
+ type WriteMigrationLockfileInput = {
16
+ baseDir: string;
17
+ connectorType: ActiveConnectorType;
18
+ lockfile: Omit<MigrateTypes.MigrationLockfile, 'content'>;
19
+ };
20
+ export declare function writeMigrationLockfile({ baseDir, connectorType, lockfile }: WriteMigrationLockfileInput): Promise<void>;
21
+ export {};
@@ -1,3 +1,4 @@
1
+ import { DataSource } from '@prisma/generator-helper';
1
2
  import type { DatabaseCredentials } from '@prisma/internals';
2
3
  import { ConnectorType } from './printDatasources';
3
4
  export type MigrateAction = 'create' | 'apply' | 'unapply' | 'dev' | 'push';
@@ -12,12 +13,9 @@ export type DatasourceInfo = {
12
13
  schemas?: string[];
13
14
  configDir?: string;
14
15
  };
15
- export declare function getDatasourceInfo({ schemaPath, throwIfEnvError, }?: {
16
- schemaPath?: string;
17
- throwIfEnvError?: boolean;
18
- }): Promise<DatasourceInfo>;
19
- export declare function ensureCanConnectToDatabase(schemaPath?: string): Promise<Boolean | Error>;
20
- export declare function ensureDatabaseExists(action: MigrateAction, schemaPath?: string): Promise<string | undefined>;
16
+ export declare function parseDatasourceInfo(datasource: DataSource | undefined): DatasourceInfo;
17
+ export declare function ensureCanConnectToDatabase(datasource: DataSource | undefined): Promise<Boolean | Error>;
18
+ export declare function ensureDatabaseExists(datasource: DataSource | undefined): Promise<string | undefined>;
21
19
  export declare function getDbLocation(credentials: DatabaseCredentials): string | undefined;
22
20
  /**
23
21
  * Return a pretty version of a "provider" (with uppercase characters)
@@ -0,0 +1,9 @@
1
+ import type { MigrateTypes } from '@prisma/internals';
2
+ /**
3
+ * Lists migrations present in the migrations directory, sorted lexicographically by name.
4
+ * Returns an empty array if the directory doesn't exist.
5
+ *
6
+ * @param migrationsDirectoryPath Absolute path to the migrations directory
7
+ * @returns Promise resolving to a sorted list of migrations
8
+ */
9
+ export declare function listMigrations(migrationsDirectoryPath: string): Promise<MigrateTypes.MigrationList>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var createMigration_exports = {};
20
+ __export(createMigration_exports, {
21
+ createMigration: () => import_chunk_23DZXSTI.createMigration,
22
+ writeMigrationLockfile: () => import_chunk_23DZXSTI.writeMigrationLockfile,
23
+ writeMigrationScript: () => import_chunk_23DZXSTI.writeMigrationScript
24
+ });
25
+ module.exports = __toCommonJS(createMigration_exports);
26
+ var import_chunk_23DZXSTI = require("../chunk-23DZXSTI.js");
27
+ var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");
@@ -18,14 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var ensureDatabaseExists_exports = {};
20
20
  __export(ensureDatabaseExists_exports, {
21
- ensureCanConnectToDatabase: () => import_chunk_DJMFXNR4.ensureCanConnectToDatabase,
22
- ensureDatabaseExists: () => import_chunk_DJMFXNR4.ensureDatabaseExists,
23
- getDatasourceInfo: () => import_chunk_DJMFXNR4.getDatasourceInfo,
24
- getDbLocation: () => import_chunk_DJMFXNR4.getDbLocation,
25
- prettifyProvider: () => import_chunk_DJMFXNR4.prettifyProvider
21
+ ensureCanConnectToDatabase: () => import_chunk_74LUB4XX.ensureCanConnectToDatabase,
22
+ ensureDatabaseExists: () => import_chunk_74LUB4XX.ensureDatabaseExists,
23
+ getDbLocation: () => import_chunk_74LUB4XX.getDbLocation,
24
+ parseDatasourceInfo: () => import_chunk_74LUB4XX.parseDatasourceInfo,
25
+ prettifyProvider: () => import_chunk_74LUB4XX.prettifyProvider
26
26
  });
27
27
  module.exports = __toCommonJS(ensureDatabaseExists_exports);
28
- var import_chunk_DJMFXNR4 = require("../chunk-DJMFXNR4.js");
28
+ var import_chunk_74LUB4XX = require("../chunk-74LUB4XX.js");
29
29
  var import_chunk_TWPTG4XS = require("../chunk-TWPTG4XS.js");
30
30
  var import_chunk_SKRR5WT4 = require("../chunk-SKRR5WT4.js");
31
31
  var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");
@@ -18,11 +18,11 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var getDatabaseVersionSafe_exports = {};
20
20
  __export(getDatabaseVersionSafe_exports, {
21
- getDatabaseVersionSafe: () => import_chunk_MKS2ZJJ5.getDatabaseVersionSafe
21
+ getDatabaseVersionSafe: () => import_chunk_MTJFLQI4.getDatabaseVersionSafe
22
22
  });
23
23
  module.exports = __toCommonJS(getDatabaseVersionSafe_exports);
24
- var import_chunk_MKS2ZJJ5 = require("../chunk-MKS2ZJJ5.js");
25
- var import_chunk_K43RXWQY = require("../chunk-K43RXWQY.js");
24
+ var import_chunk_MTJFLQI4 = require("../chunk-MTJFLQI4.js");
25
+ var import_chunk_GHZAN2PG = require("../chunk-GHZAN2PG.js");
26
26
  var import_chunk_G7PJKEOV = require("../chunk-G7PJKEOV.js");
27
27
  var import_chunk_L6KOIJJ5 = require("../chunk-L6KOIJJ5.js");
28
28
  var import_chunk_SKRR5WT4 = require("../chunk-SKRR5WT4.js");
@@ -18,11 +18,11 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var introspectSql_exports = {};
20
20
  __export(introspectSql_exports, {
21
- introspectSql: () => import_chunk_IWC5MH4R.introspectSql
21
+ introspectSql: () => import_chunk_ABQZ5J74.introspectSql
22
22
  });
23
23
  module.exports = __toCommonJS(introspectSql_exports);
24
- var import_chunk_IWC5MH4R = require("../chunk-IWC5MH4R.js");
25
- var import_chunk_K43RXWQY = require("../chunk-K43RXWQY.js");
24
+ var import_chunk_ABQZ5J74 = require("../chunk-ABQZ5J74.js");
25
+ var import_chunk_GHZAN2PG = require("../chunk-GHZAN2PG.js");
26
26
  var import_chunk_G7PJKEOV = require("../chunk-G7PJKEOV.js");
27
27
  var import_chunk_L6KOIJJ5 = require("../chunk-L6KOIJJ5.js");
28
28
  var import_chunk_SKRR5WT4 = require("../chunk-SKRR5WT4.js");
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var listMigrations_exports = {};
20
+ __export(listMigrations_exports, {
21
+ listMigrations: () => import_chunk_V6PVGSDJ.listMigrations
22
+ });
23
+ module.exports = __toCommonJS(listMigrations_exports);
24
+ var import_chunk_V6PVGSDJ = require("../chunk-V6PVGSDJ.js");
25
+ var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");
@@ -32,8 +32,8 @@ __export(setupMSSQL_exports, {
32
32
  tearDownMSSQL: () => tearDownMSSQL
33
33
  });
34
34
  module.exports = __toCommonJS(setupMSSQL_exports);
35
- var import_chunk_EJUXYFV3 = require("../chunk-EJUXYFV3.js");
36
35
  var import_chunk_5R44VVVX = require("../chunk-5R44VVVX.js");
36
+ var import_chunk_EJUXYFV3 = require("../chunk-EJUXYFV3.js");
37
37
  var import_chunk_ZB5NPOJW = require("../chunk-ZB5NPOJW.js");
38
38
  var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");
39
39
  var import_util = __toESM(require("util"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/migrate",
3
- "version": "6.6.0-dev.27",
3
+ "version": "6.6.0-dev.29",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/migrate/src/index.d.ts",
@@ -55,13 +55,13 @@
55
55
  "@prisma/internals": "*"
56
56
  },
57
57
  "dependencies": {
58
- "@prisma/engines-version": "6.6.0-20.9f8c15a33bec92b7c6d2a261f499c94ab1fa69bc",
58
+ "@prisma/engines-version": "6.6.0-21.d1dbe8880430b6f753dffc4264de1a7f39e4a15a",
59
59
  "prompts": "2.4.2",
60
- "@prisma/config": "6.6.0-dev.27",
61
- "@prisma/get-platform": "6.6.0-dev.27",
62
- "@prisma/internals": "6.6.0-dev.27",
63
- "@prisma/debug": "6.6.0-dev.27",
64
- "@prisma/generator-helper": "6.6.0-dev.27"
60
+ "@prisma/config": "6.6.0-dev.29",
61
+ "@prisma/generator-helper": "6.6.0-dev.29",
62
+ "@prisma/internals": "6.6.0-dev.29",
63
+ "@prisma/get-platform": "6.6.0-dev.29",
64
+ "@prisma/debug": "6.6.0-dev.29"
65
65
  },
66
66
  "files": [
67
67
  "README.md",