drizzle-kit 0.20.14-22fcd3b → 0.20.14-5df59eb

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 (40) hide show
  1. package/bin.cjs +41504 -41681
  2. package/cli/commands/check.d.ts +2 -0
  3. package/cli/commands/drop.d.ts +4 -0
  4. package/cli/commands/migrate.d.ts +7 -7
  5. package/cli/commands/mysqlIntrospect.d.ts +119 -0
  6. package/cli/commands/mysqlPushUtils.d.ts +18 -0
  7. package/cli/commands/mysqlUp.d.ts +1 -1
  8. package/cli/commands/pgConnect.d.ts +1 -1
  9. package/cli/commands/pgIntrospect.d.ts +1 -1
  10. package/cli/commands/pgPushUtils.d.ts +2 -2
  11. package/cli/commands/pgUp.d.ts +1 -1
  12. package/cli/commands/push.d.ts +6 -0
  13. package/cli/commands/sqlitePushUtils.d.ts +21 -0
  14. package/cli/commands/sqliteUp.d.ts +2 -0
  15. package/cli/commands/upFolders.d.ts +1 -1
  16. package/cli/commands/utils.d.ts +11 -2
  17. package/cli/index.d.ts +71 -0
  18. package/cli/validations/common.d.ts +1 -1
  19. package/cli/validations/studio.d.ts +16 -16
  20. package/cli/views.d.ts +1 -1
  21. package/drivers/index.d.ts +14 -0
  22. package/global.d.ts +1 -0
  23. package/introspect-mysql.d.ts +9 -0
  24. package/package.json +15 -3
  25. package/payload.d.mts +33 -0
  26. package/payload.d.ts +33 -0
  27. package/payload.js +37000 -0
  28. package/payload.mjs +37019 -0
  29. package/schemaValidator.d.ts +1 -1
  30. package/serializer/mysqlImports.d.ts +5 -0
  31. package/serializer/mysqlSerializer.d.ts +4 -4
  32. package/serializer/sqliteImports.d.ts +4 -0
  33. package/serializer/sqliteSerializer.d.ts +2 -2
  34. package/serializer/studioUtils.d.ts +7 -7
  35. package/utils/certs.d.ts +4 -0
  36. package/utils-studio.js +12 -7
  37. package/utils-studio.mjs +12 -7
  38. package/utils.d.ts +1 -15
  39. package/utils.js +3629 -54850
  40. package/utils.mjs +8076 -0
@@ -1,5 +1,5 @@
1
1
  import { TypeOf } from "zod";
2
- declare const dialect: import("zod").ZodEnum<["pg", "mysql", "sqlite"]>;
2
+ export declare const dialect: import("zod").ZodEnum<["pg", "mysql", "sqlite"]>;
3
3
  export type Dialect = TypeOf<typeof dialect>;
4
4
  declare const commonSquashedSchema: import("zod").ZodUnion<[import("zod").ZodObject<{
5
5
  version: import("zod").ZodLiteral<"5">;
@@ -1,4 +1,9 @@
1
1
  import { AnyMySqlTable, MySqlSchema } from "drizzle-orm/mysql-core";
2
+ export declare const prepareFromExports: (exports: Record<string, unknown>) => {
3
+ tables: AnyMySqlTable<{}>[];
4
+ enums: any[];
5
+ schemas: MySqlSchema<string>[];
6
+ };
2
7
  export declare const prepareFromMySqlImports: (imports: string[]) => Promise<{
3
8
  tables: AnyMySqlTable<{}>[];
4
9
  enums: any[];
@@ -1,7 +1,7 @@
1
1
  import { AnyMySqlTable, MySqlSchema } from "drizzle-orm/mysql-core";
2
- import { MySqlSchemaInternal } from "src/serializer/mysqlSchema";
3
- import { Connection } from "mysql2/promise";
4
- import { IntrospectStage, IntrospectStatus } from "src/cli/views";
2
+ import { MySqlSchemaInternal } from "../serializer/mysqlSchema";
3
+ import { IntrospectStage, IntrospectStatus } from "../cli/views";
4
+ import { DrizzleDbClient } from "src/drivers";
5
5
  export declare const indexName: (tableName: string, columns: string[]) => string;
6
6
  export declare const generateMySqlSnapshot: (tables: AnyMySqlTable[], enums: any[], mysqlSchemas: MySqlSchema[]) => MySqlSchemaInternal;
7
- export declare const fromDatabase: (db: Connection, inputSchema: string, tablesFilter?: (table: string) => boolean, progressCallback?: ((stage: IntrospectStage, count: number, status: IntrospectStatus) => void) | undefined) => Promise<MySqlSchemaInternal>;
7
+ export declare const fromDatabase: (db: DrizzleDbClient, inputSchema: string, tablesFilter?: (table: string) => boolean, progressCallback?: ((stage: IntrospectStage, count: number, status: IntrospectStatus) => void) | undefined) => Promise<MySqlSchemaInternal>;
@@ -1,4 +1,8 @@
1
1
  import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
2
+ export declare const prepareFromExports: (exports: Record<string, unknown>) => {
3
+ tables: AnySQLiteTable<{}>[];
4
+ enums: any[];
5
+ };
2
6
  export declare const prepareFromSqliteImports: (imports: string[]) => Promise<{
3
7
  tables: AnySQLiteTable<{}>[];
4
8
  enums: any[];
@@ -1,6 +1,6 @@
1
1
  import type { SQLiteSchemaInternal } from "../serializer/sqliteSchema";
2
2
  import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
3
- import type { IntrospectStage, IntrospectStatus } from "src/cli/views";
4
- import type { DrizzleDbClient } from "src/drivers";
3
+ import type { IntrospectStage, IntrospectStatus } from "../cli/views";
4
+ import type { DrizzleDbClient } from "../drivers";
5
5
  export declare const generateSqliteSnapshot: (tables: AnySQLiteTable[], enums: any[]) => SQLiteSchemaInternal;
6
6
  export declare const fromDatabase: (db: DrizzleDbClient, tablesFilter?: (table: string) => boolean, progressCallback?: ((stage: IntrospectStage, count: number, status: IntrospectStatus) => void) | undefined) => Promise<SQLiteSchemaInternal>;
@@ -3,9 +3,9 @@ import { Relations } from "drizzle-orm";
3
3
  import { AnyMySqlTable } from "drizzle-orm/mysql-core";
4
4
  import { AnyPgTable } from "drizzle-orm/pg-core";
5
5
  import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
6
- import { MySQLConnectionConfig } from "src/cli/validations/mysql";
7
- import { PgConnectionConfig } from "src/cli/validations/pg";
8
- import { StudioConfigConnections, StudioSqliteConnectionConfig as StudioSQLiteConnectionConfig } from "src/cli/validations/studio";
6
+ import { MySQLConnectionConfig } from "../cli/validations/mysql";
7
+ import { PgConnectionConfig } from "../cli/validations/pg";
8
+ import { StudioConfigConnections, StudioSqliteConnectionConfig as StudioSQLiteConnectionConfig } from "../cli/validations/studio";
9
9
  export declare const preparePgSchema: (path: string | string[]) => Promise<{
10
10
  schema: Record<string, Record<string, AnyPgTable<{}>>>;
11
11
  relations: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
@@ -21,7 +21,7 @@ export declare const prepareSQLiteSchema: (path: string | string[]) => Promise<{
21
21
  export declare const prepareModels: (path: string | string[]) => Promise<{
22
22
  pgSchema: Record<string, AnyPgTable<{}> | Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
23
23
  mysqlSchema: Record<string, AnyMySqlTable<{}> | Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
24
- sqliteSchema: Record<string, AnySQLiteTable<{}> | Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
24
+ sqliteSchema: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>> | AnySQLiteTable<{}>>;
25
25
  }>;
26
26
  export declare const drizzleForPostgres: (connectionConfig: PgConnectionConfig, pgSchema: Record<string, Record<string, AnyPgTable>>, relations: Record<string, Relations>, ts: {
27
27
  imports: string;
@@ -53,13 +53,13 @@ export declare const drizzleDb: (drizzleConfig: StudioConfigConnections, models:
53
53
  } | {
54
54
  db: import("../orm-extenstions/d1-driver/driver").DrizzleD1WranglerDatabase<Record<string, never>>;
55
55
  type: "sqlite";
56
- schema: Record<string, AnySQLiteTable<{}> | Relations<string, Record<string, import("drizzle-orm").Relation<string>>>> | undefined;
56
+ schema: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>> | AnySQLiteTable<{}>> | undefined;
57
57
  } | {
58
58
  db: import("drizzle-orm/better-sqlite3").BetterSQLite3Database<Record<string, never>>;
59
59
  type: "sqlite";
60
- schema: Record<string, AnySQLiteTable<{}> | Relations<string, Record<string, import("drizzle-orm").Relation<string>>>> | undefined;
60
+ schema: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>> | AnySQLiteTable<{}>> | undefined;
61
61
  } | {
62
62
  db: import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>>;
63
63
  type: "sqlite";
64
- schema: Record<string, AnySQLiteTable<{}> | Relations<string, Record<string, import("drizzle-orm").Relation<string>>>> | undefined;
64
+ schema: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>> | AnySQLiteTable<{}>> | undefined;
65
65
  }>;
@@ -0,0 +1,4 @@
1
+ export declare const certs: () => Promise<{
2
+ key: string;
3
+ cert: string;
4
+ } | null>;
package/utils-studio.js CHANGED
@@ -1081,6 +1081,14 @@ var init_views = __esm({
1081
1081
  }
1082
1082
  });
1083
1083
 
1084
+ // src/global.ts
1085
+ var originUUID;
1086
+ var init_global = __esm({
1087
+ "src/global.ts"() {
1088
+ originUUID = "00000000-0000-0000-0000-000000000000";
1089
+ }
1090
+ });
1091
+
1084
1092
  // src/serializer/index.ts
1085
1093
  var glob;
1086
1094
  var init_serializer = __esm({
@@ -1571,7 +1579,7 @@ var init_pgSerializer = __esm({
1571
1579
  --end;
1572
1580
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
1573
1581
  };
1574
- fromDatabase2 = async (db, tablesFilter = (table) => true, schemaFilters, progressCallback) => {
1582
+ fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
1575
1583
  const result = {};
1576
1584
  const internals = { tables: {} };
1577
1585
  const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
@@ -1631,7 +1639,7 @@ var init_pgSerializer = __esm({
1631
1639
  END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, INFORMATION_SCHEMA.COLUMNS.column_name, INFORMATION_SCHEMA.COLUMNS.column_default, INFORMATION_SCHEMA.COLUMNS.data_type as additional_dt
1632
1640
  FROM pg_attribute a
1633
1641
  JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
1634
- WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}'
1642
+ WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}' and INFORMATION_SCHEMA.COLUMNS.table_schema = '${tableSchema}'
1635
1643
  AND a.attnum > 0
1636
1644
  AND NOT a.attisdropped
1637
1645
  ORDER BY a.attnum;`
@@ -2166,11 +2174,7 @@ var sqliteSchemaToDrizzle = (schema) => {
2166
2174
 
2167
2175
  // src/cli/commands/sqliteIntrospect.ts
2168
2176
  init_views();
2169
-
2170
- // src/global.ts
2171
- var originUUID = "00000000-0000-0000-0000-000000000000";
2172
-
2173
- // src/cli/commands/sqliteIntrospect.ts
2177
+ init_global();
2174
2178
  init_sqliteSerializer();
2175
2179
 
2176
2180
  // node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
@@ -3356,6 +3360,7 @@ var import_relations = require("drizzle-orm/relations");
3356
3360
  init_pgSerializer();
3357
3361
 
3358
3362
  // src/cli/commands/pgIntrospect.ts
3363
+ init_global();
3359
3364
  var pgPushIntrospect = async (connection, filters, schemaFilters) => {
3360
3365
  const { client } = connection;
3361
3366
  const matchers = filters.map((it) => {
package/utils-studio.mjs CHANGED
@@ -1083,6 +1083,14 @@ var init_views = __esm({
1083
1083
  }
1084
1084
  });
1085
1085
 
1086
+ // src/global.ts
1087
+ var originUUID;
1088
+ var init_global = __esm({
1089
+ "src/global.ts"() {
1090
+ originUUID = "00000000-0000-0000-0000-000000000000";
1091
+ }
1092
+ });
1093
+
1086
1094
  // src/serializer/index.ts
1087
1095
  import * as glob from "glob";
1088
1096
  var init_serializer = __esm({
@@ -1580,7 +1588,7 @@ var init_pgSerializer = __esm({
1580
1588
  --end;
1581
1589
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
1582
1590
  };
1583
- fromDatabase2 = async (db, tablesFilter = (table) => true, schemaFilters, progressCallback) => {
1591
+ fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
1584
1592
  const result = {};
1585
1593
  const internals = { tables: {} };
1586
1594
  const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
@@ -1640,7 +1648,7 @@ var init_pgSerializer = __esm({
1640
1648
  END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, INFORMATION_SCHEMA.COLUMNS.column_name, INFORMATION_SCHEMA.COLUMNS.column_default, INFORMATION_SCHEMA.COLUMNS.data_type as additional_dt
1641
1649
  FROM pg_attribute a
1642
1650
  JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
1643
- WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}'
1651
+ WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}' and INFORMATION_SCHEMA.COLUMNS.table_schema = '${tableSchema}'
1644
1652
  AND a.attnum > 0
1645
1653
  AND NOT a.attisdropped
1646
1654
  ORDER BY a.attnum;`
@@ -2200,11 +2208,7 @@ var sqliteSchemaToDrizzle = (schema) => {
2200
2208
 
2201
2209
  // src/cli/commands/sqliteIntrospect.ts
2202
2210
  init_views();
2203
-
2204
- // src/global.ts
2205
- var originUUID = "00000000-0000-0000-0000-000000000000";
2206
-
2207
- // src/cli/commands/sqliteIntrospect.ts
2211
+ init_global();
2208
2212
  init_sqliteSerializer();
2209
2213
 
2210
2214
  // node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
@@ -3395,6 +3399,7 @@ import {
3395
3399
  init_pgSerializer();
3396
3400
 
3397
3401
  // src/cli/commands/pgIntrospect.ts
3402
+ init_global();
3398
3403
  var pgPushIntrospect = async (connection, filters, schemaFilters) => {
3399
3404
  const { client } = connection;
3400
3405
  const matchers = filters.map((it) => {
package/utils.d.ts CHANGED
@@ -1,8 +1,5 @@
1
- import { Dialect } from "./schemaValidator";
1
+ import type { Dialect } from "./schemaValidator";
2
2
  import { NamedWithSchema } from "./cli/commands/migrate";
3
- import { PgDatabase } from "drizzle-orm/pg-core";
4
- import { PgSchema as PgSchemaKit } from "./serializer/pgSchema";
5
- import { DbConnection } from ".";
6
3
  export declare const assertV1OutFolder: (out: string, dialect: Dialect | "{dialect}") => void;
7
4
  export type Journal = {
8
5
  version: string;
@@ -22,7 +19,6 @@ export declare const prepareOutFolder: (out: string, dialect: Dialect) => {
22
19
  snapshots: string[];
23
20
  journal: any;
24
21
  };
25
- export declare const mapValues: <IN, OUT>(obj: Record<string, IN>, map: (input: IN) => OUT) => Record<string, OUT>;
26
22
  export declare const validateWithReport: (snapshots: string[], dialect: Dialect) => {
27
23
  malformed: string[];
28
24
  nonLatest: string[];
@@ -201,13 +197,3 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
201
197
  columns: {};
202
198
  } | undefined;
203
199
  }>;
204
- export type DrizzleSnapshotJSON = PgSchemaKit;
205
- export declare const generateDrizzleJson: (imports: Record<string, unknown>, prevId?: string) => PgSchemaKit;
206
- export declare const generateMigration: (prev: DrizzleSnapshotJSON, cur: DrizzleSnapshotJSON) => Promise<string[]>;
207
- export declare const pushSchema: (imports: Record<string, unknown>, db: PgDatabase<any>) => Promise<{
208
- hasDataLoss: boolean;
209
- warnings: string[];
210
- statementsToExecute: string[];
211
- apply: () => Promise<void>;
212
- }>;
213
- export declare const prepareFrom: (connection: DbConnection) => Promise<Record<string, any>>;