drizzle-kit 0.20.1-85fc559 → 0.20.2-8e648e0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,114 @@
1
+ import { MySQLConfigIntrospect, MySQLConnectionConfig } from "../validations/mysql";
2
+ import { DrizzleDbClient, MySQL2Client } from "src/drivers";
3
+ export declare const connectToMySQL: (config: MySQLConnectionConfig) => Promise<{
4
+ client: MySQL2Client;
5
+ databaseName: string;
6
+ }>;
7
+ export declare const mysqlIntrospect: (config: MySQLConfigIntrospect, filters: string[]) => Promise<{
8
+ schema: {
9
+ id: string;
10
+ prevId: string;
11
+ version: "5";
12
+ dialect: "mysql";
13
+ tables: Record<string, {
14
+ schema?: string | undefined;
15
+ name: string;
16
+ columns: Record<string, {
17
+ default?: any;
18
+ onUpdate?: any;
19
+ autoincrement?: boolean | undefined;
20
+ name: string;
21
+ type: string;
22
+ primaryKey: boolean;
23
+ notNull: boolean;
24
+ }>;
25
+ indexes: Record<string, {
26
+ using?: "btree" | "hash" | undefined;
27
+ algorithm?: "default" | "inplace" | "copy" | undefined;
28
+ lock?: "default" | "none" | "shared" | "exclusive" | undefined;
29
+ name: string;
30
+ columns: string[];
31
+ isUnique: boolean;
32
+ }>;
33
+ foreignKeys: Record<string, {
34
+ onUpdate?: string | undefined;
35
+ onDelete?: string | undefined;
36
+ name: string;
37
+ tableFrom: string;
38
+ columnsFrom: string[];
39
+ tableTo: string;
40
+ columnsTo: string[];
41
+ }>;
42
+ compositePrimaryKeys: Record<string, {
43
+ name: string;
44
+ columns: string[];
45
+ }>;
46
+ uniqueConstraints: Record<string, {
47
+ name: string;
48
+ columns: string[];
49
+ }>;
50
+ }>;
51
+ schemas: Record<string, string>;
52
+ _meta: {
53
+ columns: Record<string, string>;
54
+ tables: Record<string, string>;
55
+ schemas: Record<string, string>;
56
+ };
57
+ };
58
+ ts: string;
59
+ }>;
60
+ export declare const mysqlPushIntrospect: (connection: {
61
+ client: DrizzleDbClient;
62
+ databaseName: string;
63
+ }, filters: string[]) => Promise<{
64
+ schema: {
65
+ id: string;
66
+ prevId: string;
67
+ version: "5";
68
+ dialect: "mysql";
69
+ tables: Record<string, {
70
+ schema?: string | undefined;
71
+ name: string;
72
+ columns: Record<string, {
73
+ default?: any;
74
+ onUpdate?: any;
75
+ autoincrement?: boolean | undefined;
76
+ name: string;
77
+ type: string;
78
+ primaryKey: boolean;
79
+ notNull: boolean;
80
+ }>;
81
+ indexes: Record<string, {
82
+ using?: "btree" | "hash" | undefined;
83
+ algorithm?: "default" | "inplace" | "copy" | undefined;
84
+ lock?: "default" | "none" | "shared" | "exclusive" | undefined;
85
+ name: string;
86
+ columns: string[];
87
+ isUnique: boolean;
88
+ }>;
89
+ foreignKeys: Record<string, {
90
+ onUpdate?: string | undefined;
91
+ onDelete?: string | undefined;
92
+ name: string;
93
+ tableFrom: string;
94
+ columnsFrom: string[];
95
+ tableTo: string;
96
+ columnsTo: string[];
97
+ }>;
98
+ compositePrimaryKeys: Record<string, {
99
+ name: string;
100
+ columns: string[];
101
+ }>;
102
+ uniqueConstraints: Record<string, {
103
+ name: string;
104
+ columns: string[];
105
+ }>;
106
+ }>;
107
+ schemas: Record<string, string>;
108
+ _meta: {
109
+ columns: Record<string, string>;
110
+ tables: Record<string, string>;
111
+ schemas: Record<string, string>;
112
+ };
113
+ };
114
+ }>;
@@ -0,0 +1,17 @@
1
+ import { DrizzleDbClient } from "src/drivers";
2
+ import { JsonStatement } from "src/jsonStatements";
3
+ import { mysqlSchema } from "src/serializer/mysqlSchema";
4
+ import { TypeOf } from "zod";
5
+ export declare const filterStatements: (statements: JsonStatement[], currentSchema: TypeOf<typeof mysqlSchema>, prevSchema: TypeOf<typeof mysqlSchema>) => JsonStatement[];
6
+ export declare const logSuggestionsAndReturn: ({ connection, statements, }: {
7
+ statements: JsonStatement[];
8
+ connection: DrizzleDbClient;
9
+ }) => Promise<{
10
+ statementsToExecute: string[];
11
+ shouldAskForApprove: boolean;
12
+ infoToPrint: string[];
13
+ columnsToRemove: string[];
14
+ schemasToRemove: string[];
15
+ tablesToTruncate: string[];
16
+ tablesToRemove: string[];
17
+ }>;
@@ -0,0 +1,21 @@
1
+ import { DrizzleDbClient } from "src/drivers";
2
+ import { JsonStatement } from "src/jsonStatements";
3
+ import { SQLiteSchemaInternal, SQLiteSchemaSquashed } from "src/serializer/sqliteSchema";
4
+ export declare const _moveDataStatements: (tableName: string, json: SQLiteSchemaSquashed, dataLoss?: boolean) => string[];
5
+ export declare const getOldTableName: (tableName: string, meta: SQLiteSchemaInternal["_meta"]) => string;
6
+ export declare const getNewTableName: (tableName: string, meta: SQLiteSchemaInternal["_meta"]) => string;
7
+ export declare const logSuggestionsAndReturn: ({ connection, statements, json1, json2, meta, }: {
8
+ statements: JsonStatement[];
9
+ connection: DrizzleDbClient;
10
+ json1: SQLiteSchemaSquashed;
11
+ json2: SQLiteSchemaSquashed;
12
+ meta: SQLiteSchemaInternal["_meta"];
13
+ }) => Promise<{
14
+ statementsToExecute: string[];
15
+ shouldAskForApprove: boolean;
16
+ infoToPrint: string[];
17
+ columnsToRemove: string[];
18
+ schemasToRemove: string[];
19
+ tablesToTruncate: string[];
20
+ tablesToRemove: string[];
21
+ }>;
@@ -1,4 +1,6 @@
1
1
  import type { Client } from "@libsql/client";
2
+ import { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
3
+ import { MySql2Database } from "drizzle-orm/mysql2";
2
4
  import type { PgDatabase } from "drizzle-orm/pg-core";
3
5
  import type { Client as PgClient } from "pg";
4
6
  export declare abstract class DrizzleDbClient<T = any> {
@@ -11,10 +13,22 @@ export declare class DrizzleORMPgClient extends DrizzleDbClient<PgDatabase<any>>
11
13
  query<K = any>(query: string, values?: any[] | undefined): Promise<K[]>;
12
14
  run(query: string): Promise<void>;
13
15
  }
16
+ export declare class DrizzleORMMySQLClient extends DrizzleDbClient<MySql2Database<any>> {
17
+ query<K = any>(query: string, values?: any[] | undefined): Promise<K[]>;
18
+ run(query: string): Promise<void>;
19
+ }
20
+ export declare class DrizzleORMSQLiteClient extends DrizzleDbClient<BetterSQLite3Database<any>> {
21
+ query<K = any>(query: string, values?: any[] | undefined): Promise<K[]>;
22
+ run(query: string): Promise<void>;
23
+ }
14
24
  export declare class BetterSqlite extends DrizzleDbClient {
15
25
  run(query: string): Promise<void>;
16
26
  query(query: string): Promise<any[]>;
17
27
  }
28
+ export declare class MySQL2Client extends DrizzleDbClient {
29
+ run(query: string): Promise<void>;
30
+ query(query: string): Promise<any>;
31
+ }
18
32
  export declare class TursoSqlite extends DrizzleDbClient<Client> {
19
33
  run(query: string): Promise<void>;
20
34
  query(query: string): Promise<any[]>;
@@ -0,0 +1,4 @@
1
+ import "./@types/utils";
2
+ import { ConfigIntrospectCasing } from "./cli/commands/utils";
3
+ import { MySqlSchema } from "./serializer/mysqlSchema";
4
+ export declare const schemaToTypeScript: (schema: MySqlSchema, casing: ConfigIntrospectCasing["casing"]) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.20.1-85fc559",
3
+ "version": "0.20.2-8e648e0",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
@@ -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
2
  import { MySqlSchemaInternal } from "src/serializer/mysqlSchema";
3
- import { Connection } from "mysql2/promise";
4
3
  import { IntrospectStage, IntrospectStatus } from "src/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[];
package/utils.d.ts CHANGED
@@ -2,7 +2,11 @@ import { Dialect } from "./schemaValidator";
2
2
  import { NamedWithSchema } from "./cli/commands/migrate";
3
3
  import { PgDatabase } from "drizzle-orm/pg-core";
4
4
  import { PgSchema as PgSchemaKit } from "./serializer/pgSchema";
5
+ import { SQLiteSchema as SQLiteSchemaKit } from "./serializer/sqliteSchema";
6
+ import { MySqlSchema as MySQLSchemaKit } from "./serializer/mysqlSchema";
5
7
  import { DbConnection } from ".";
8
+ import { MySql2Database } from "drizzle-orm/mysql2";
9
+ import { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
6
10
  export declare const assertV1OutFolder: (out: string, dialect: Dialect | "{dialect}") => void;
7
11
  export type Journal = {
8
12
  version: string;
@@ -200,6 +204,8 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
200
204
  } | undefined;
201
205
  }>;
202
206
  export type DrizzleSnapshotJSON = PgSchemaKit;
207
+ export type DrizzleSQLiteSnapshotJSON = SQLiteSchemaKit;
208
+ export type DrizzleMySQLSnapshotJSON = MySQLSchemaKit;
203
209
  export declare const generateDrizzleJson: (imports: Record<string, unknown>, prevId?: string) => PgSchemaKit;
204
210
  export declare const generateMigration: (prev: DrizzleSnapshotJSON, cur: DrizzleSnapshotJSON) => Promise<string[]>;
205
211
  export declare const pushSchema: (imports: Record<string, unknown>, db: PgDatabase<any>) => Promise<{
@@ -209,3 +215,19 @@ export declare const pushSchema: (imports: Record<string, unknown>, db: PgDataba
209
215
  apply: () => Promise<void>;
210
216
  }>;
211
217
  export declare const prepareFrom: (connection: DbConnection) => Promise<Record<string, any>>;
218
+ export declare const generateSQLiteDrizzleJson: (imports: Record<string, unknown>, prevId?: string) => Promise<SQLiteSchemaKit>;
219
+ export declare const generateSQLiteMigration: (prev: DrizzleSQLiteSnapshotJSON, cur: DrizzleSQLiteSnapshotJSON) => Promise<string[]>;
220
+ export declare const pushSQLiteSchema: (imports: Record<string, unknown>, db: BetterSQLite3Database<any>) => Promise<{
221
+ hasDataLoss: boolean;
222
+ warnings: string[];
223
+ statementsToExecute: string[];
224
+ apply: () => Promise<void>;
225
+ }>;
226
+ export declare const generateMySQLDrizzleJson: (imports: Record<string, unknown>, prevId?: string) => Promise<MySQLSchemaKit>;
227
+ export declare const generateMySQLMigration: (prev: DrizzleMySQLSnapshotJSON, cur: DrizzleMySQLSnapshotJSON) => Promise<string[]>;
228
+ export declare const pushMySQLSchema: (imports: Record<string, unknown>, db: MySql2Database<any>, databaseName: string) => Promise<{
229
+ hasDataLoss: boolean;
230
+ warnings: string[];
231
+ statementsToExecute: string[];
232
+ apply: () => Promise<void>;
233
+ }>;