drizzle-kit 0.20.0-8d6aad7 → 0.20.0-a6a840b

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.
package/index.d.ts CHANGED
@@ -41,7 +41,7 @@ export type DbConnection = {
41
41
  password?: string;
42
42
  database: string;
43
43
  } | {
44
- connectionString: string;
44
+ uri: string;
45
45
  };
46
46
  };
47
47
  export type Config = {
@@ -93,7 +93,7 @@ export type Config = {
93
93
  password?: string;
94
94
  database: string;
95
95
  } | {
96
- connectionString: string;
96
+ uri: string;
97
97
  };
98
98
  } | {
99
99
  driver: "d1";
@@ -2,10 +2,9 @@ import { entityKind } from "drizzle-orm";
2
2
  import type { Logger } from "drizzle-orm";
3
3
  import { type RelationalSchemaConfig, type TablesRelationalConfig } from "drizzle-orm";
4
4
  import { type Query } from "drizzle-orm";
5
- import type { SQLiteAsyncDialect, SQLiteExecuteMethod } from "drizzle-orm/sqlite-core";
5
+ import { SQLiteAsyncDialect, SQLiteExecuteMethod, SQLitePreparedQuery, SQLiteSession } from "drizzle-orm/sqlite-core";
6
6
  import type { SelectedFieldsOrdered } from "drizzle-orm/sqlite-core";
7
7
  import { type PreparedQueryConfig as PreparedQueryConfigBase, type SQLiteTransactionConfig } from "drizzle-orm/sqlite-core";
8
- import { PreparedQuery as PreparedQueryBase, SQLiteSession } from "drizzle-orm/sqlite-core";
9
8
  export interface SQLiteD1SessionOptions {
10
9
  logger?: Logger;
11
10
  }
@@ -25,7 +24,7 @@ export declare class SQLiteWranglerD1Session<TFullSchema extends Record<string,
25
24
  prepareQuery(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, customResultMapper?: (rows: unknown[][]) => unknown): PreparedQuery;
26
25
  transaction<T>(transaction: (tx: any) => T | Promise<T>, config?: SQLiteTransactionConfig): Promise<T>;
27
26
  }
28
- export declare class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends PreparedQueryBase<{
27
+ export declare class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends SQLitePreparedQuery<{
29
28
  type: "async";
30
29
  run: D1WranglerResults;
31
30
  all: T["all"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.20.0-8d6aad7",
3
+ "version": "0.20.0-a6a840b",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
@@ -40,7 +40,8 @@
40
40
  "packit": "pnpm build && cp package.json dist/ && cd dist && pnpm pack",
41
41
  "tsc": "tsc -p tsconfig.build.json",
42
42
  "pub": "cp package.json readme.md dist/ && cd dist && npm publish",
43
- "studio": "./dist/index.cjs studio --verbose"
43
+ "studio": "./dist/index.cjs studio --verbose",
44
+ "studio:dev": "tsx ./src/cli/index.ts studio --verbose"
44
45
  },
45
46
  "ava": {
46
47
  "files": [
@@ -54,7 +55,7 @@
54
55
  ]
55
56
  },
56
57
  "dependencies": {
57
- "@drizzle-team/studio": "^0.0.9",
58
+ "@drizzle-team/studio": "^0.0.27",
58
59
  "@esbuild-kit/esm-loader": "^2.5.5",
59
60
  "camelcase": "^7.0.1",
60
61
  "chalk": "^5.2.0",
@@ -76,20 +77,20 @@
76
77
  "@types/glob": "^8.1.0",
77
78
  "@types/minimatch": "^5.1.2",
78
79
  "@types/node": "^18.11.15",
79
- "@types/pg": "^8.6.5",
80
+ "@types/pg": "^8.10.7",
80
81
  "@typescript-eslint/eslint-plugin": "^5.46.1",
81
82
  "@typescript-eslint/parser": "^5.46.1",
82
83
  "ava": "^5.1.0",
83
84
  "better-sqlite3": "^8.4.0",
84
85
  "dockerode": "^3.3.4",
85
86
  "dotenv": "^16.0.3",
86
- "drizzle-orm": "0.28.7-4e094f0",
87
+ "drizzle-orm": "0.29.0-d3b1c58",
87
88
  "eslint": "^8.29.0",
88
89
  "eslint-config-prettier": "^8.5.0",
89
90
  "eslint-plugin-prettier": "^4.2.1",
90
91
  "get-port": "^6.1.2",
91
92
  "mysql2": "2.3.3",
92
- "pg": "^8.8.0",
93
+ "pg": "^8.11.3",
93
94
  "postgres": "^3.3.5",
94
95
  "prettier": "^2.8.1",
95
96
  "tsx": "^3.12.1",
@@ -6,4 +6,4 @@ import type { DrizzleDbClient } from "../drivers";
6
6
  export declare const indexName: (tableName: string, columns: string[]) => string;
7
7
  export declare const generatePgSnapshot: (tables: AnyPgTable[], enums: PgEnum<any>[], schemas: PgSchema[], schemaFilter?: string[]) => PgSchemaInternal;
8
8
  export declare const fromDatabase: (db: DrizzleDbClient, tablesFilter: ((table: string) => boolean) | undefined, schemaFilters: string[], progressCallback?: ((stage: IntrospectStage, count: number, status: IntrospectStatus) => void) | undefined) => Promise<PgSchemaInternal>;
9
- export declare const toDrizzle: (schema: PgSchemaInternal) => Record<string, AnyPgTable | Relations>;
9
+ export declare const toDrizzle: (schema: PgSchemaInternal, schemaName: string) => Record<string, AnyPgTable | Relations>;
@@ -1,13 +1,31 @@
1
+ import type { Setup } from "@drizzle-team/studio";
1
2
  import { Relations } from "drizzle-orm";
2
3
  import { AnyMySqlTable } from "drizzle-orm/mysql-core";
3
4
  import { AnyPgTable } from "drizzle-orm/pg-core";
4
5
  import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
5
- import { StudioConfigConnections } from "src/cli/validations/studio";
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";
9
+ export declare const preparePgSchema: (path: string | string[]) => Promise<{
10
+ schema: Record<string, Record<string, AnyPgTable<{}>>>;
11
+ relations: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
12
+ }>;
13
+ export declare const prepareMySqlSchema: (path: string | string[]) => Promise<{
14
+ schema: Record<string, Record<string, AnyMySqlTable<{}>>>;
15
+ relations: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
16
+ }>;
17
+ export declare const prepareSQLiteSchema: (path: string | string[]) => Promise<{
18
+ schema: Record<string, Record<string, AnySQLiteTable<{}>>>;
19
+ relations: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
20
+ }>;
6
21
  export declare const prepareModels: (path: string | string[]) => Promise<{
7
22
  pgSchema: Record<string, AnyPgTable<{}> | Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
8
23
  mysqlSchema: Record<string, AnyMySqlTable<{}> | Relations<string, Record<string, import("drizzle-orm").Relation<string>>>>;
9
24
  sqliteSchema: Record<string, Relations<string, Record<string, import("drizzle-orm").Relation<string>>> | AnySQLiteTable<{}>>;
10
25
  }>;
26
+ export declare const drizzleForPostgres: (connectionConfig: PgConnectionConfig, pgSchema: Record<string, Record<string, AnyPgTable>>, relations: Record<string, Relations>, verbose: boolean) => Promise<Setup>;
27
+ export declare const drizzleForMySQL: (config: MySQLConnectionConfig, mysqlSchema: Record<string, Record<string, AnyMySqlTable>>, relations: Record<string, Relations>, verbose: boolean) => Promise<Setup>;
28
+ export declare const drizzleForSQLite: (config: StudioSQLiteConnectionConfig, sqliteSchema: Record<string, Record<string, AnySQLiteTable>>, relations: Record<string, Relations>, verbose: boolean) => Promise<Setup>;
11
29
  export declare const drizzleDb: (drizzleConfig: StudioConfigConnections, models: {
12
30
  pgSchema?: Record<string, AnyPgTable | Relations>;
13
31
  mysqlSchema?: Record<string, AnyMySqlTable | Relations>;
package/utils-studio.d.ts CHANGED
@@ -2,4 +2,4 @@ export { toDrizzle as drizzleSchemaPg } from "./serializer/pgSerializer";
2
2
  export { toDrizzle as drizzleSchemaSQLite } from "./serializer/sqliteSerializer";
3
3
  export { sqlitePushIntrospect } from "./cli/commands/sqliteIntrospect";
4
4
  export { pgPushIntrospect } from "./cli/commands/pgIntrospect";
5
- export type { DrizzleDbClient } from "./drivers";
5
+ export { DrizzleORMPgClient } from "./drivers";
package/utils-studio.js CHANGED
@@ -967,7 +967,7 @@ var init_pgSerializer = __esm({
967
967
  }
968
968
  }
969
969
  };
970
- toDrizzle = (schema) => {
970
+ toDrizzle = (schema, schemaName) => {
971
971
  const tables = {};
972
972
  Object.values(schema.tables).forEach((t) => {
973
973
  const columns = {};
@@ -1041,17 +1041,31 @@ var init_pgSerializer = __esm({
1041
1041
  }
1042
1042
  columns[columnName] = columnBuilder;
1043
1043
  });
1044
- tables[t.name] = (0, import_pg_core.pgTable)(t.name, columns, (cb) => {
1045
- const res = {};
1046
- Object.values(t.compositePrimaryKeys).forEach((cpk) => {
1047
- const gh = cpk.columns.map((c) => cb[c]);
1048
- res[cpk.name] = new import_pg_core.PrimaryKeyBuilder(
1049
- gh,
1050
- cpk.name
1051
- );
1044
+ if (schemaName === "public") {
1045
+ tables[t.name] = (0, import_pg_core.pgTable)(t.name, columns, (cb) => {
1046
+ const res = {};
1047
+ Object.values(t.compositePrimaryKeys).forEach((cpk) => {
1048
+ const gh = cpk.columns.map((c) => cb[c]);
1049
+ res[cpk.name] = new import_pg_core.PrimaryKeyBuilder(
1050
+ gh,
1051
+ cpk.name
1052
+ );
1053
+ });
1054
+ return res;
1052
1055
  });
1053
- return res;
1054
- });
1056
+ } else {
1057
+ tables[t.name] = (0, import_pg_core.pgSchema)(schemaName).table(t.name, columns, (cb) => {
1058
+ const res = {};
1059
+ Object.values(t.compositePrimaryKeys).forEach((cpk) => {
1060
+ const gh = cpk.columns.map((c) => cb[c]);
1061
+ res[cpk.name] = new import_pg_core.PrimaryKeyBuilder(
1062
+ gh,
1063
+ cpk.name
1064
+ );
1065
+ });
1066
+ return res;
1067
+ });
1068
+ }
1055
1069
  });
1056
1070
  return tables;
1057
1071
  };
@@ -2094,9 +2108,33 @@ var require_brace_expansion = __commonJS({
2094
2108
  }
2095
2109
  });
2096
2110
 
2111
+ // src/drivers/index.ts
2112
+ var import_drizzle_orm3, DrizzleDbClient, DrizzleORMPgClient;
2113
+ var init_drivers = __esm({
2114
+ "src/drivers/index.ts"() {
2115
+ import_drizzle_orm3 = require("drizzle-orm");
2116
+ DrizzleDbClient = class {
2117
+ constructor(db) {
2118
+ this.db = db;
2119
+ }
2120
+ };
2121
+ DrizzleORMPgClient = class extends DrizzleDbClient {
2122
+ async query(query, values) {
2123
+ const res = await this.db.execute(import_drizzle_orm3.sql.raw(query));
2124
+ return res.rows;
2125
+ }
2126
+ async run(query) {
2127
+ const res = await this.db.execute(import_drizzle_orm3.sql.raw(query));
2128
+ return res.rows;
2129
+ }
2130
+ };
2131
+ }
2132
+ });
2133
+
2097
2134
  // src/utils-studio.ts
2098
2135
  var utils_studio_exports = {};
2099
2136
  __export(utils_studio_exports, {
2137
+ DrizzleORMPgClient: () => DrizzleORMPgClient,
2100
2138
  drizzleSchemaPg: () => toDrizzle,
2101
2139
  drizzleSchemaSQLite: () => toDrizzle2,
2102
2140
  pgPushIntrospect: () => pgPushIntrospect,
@@ -3316,8 +3354,12 @@ var pgPushIntrospect = async (connection, filters, schemaFilters) => {
3316
3354
  const { internal, ...schemaWithoutInternals } = schema;
3317
3355
  return { schema: schemaWithoutInternals };
3318
3356
  };
3357
+
3358
+ // src/utils-studio.ts
3359
+ init_drivers();
3319
3360
  // Annotate the CommonJS export names for ESM import in node:
3320
3361
  0 && (module.exports = {
3362
+ DrizzleORMPgClient,
3321
3363
  drizzleSchemaPg,
3322
3364
  drizzleSchemaSQLite,
3323
3365
  pgPushIntrospect,
package/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Dialect } from "./schemaValidator";
2
2
  import { NamedWithSchema } from "./cli/commands/migrate";
3
- import { AnyPgTable, PgDatabase } from "drizzle-orm/pg-core";
3
+ import { PgDatabase } from "drizzle-orm/pg-core";
4
4
  import { PgSchema as PgSchemaKit } from "./serializer/pgSchema";
5
5
  import { Config, DbConnection } from ".";
6
6
  export declare const assertV1OutFolder: (out: string, dialect: Dialect | "{dialect}") => void;
@@ -209,24 +209,4 @@ export declare const pushSchema: (imports: Record<string, unknown>, db: PgDataba
209
209
  statementsToExecute: string[];
210
210
  apply: () => Promise<void>;
211
211
  }>;
212
- export declare const prepareFrom: (connection: DbConnection) => Promise<{
213
- db: import("drizzle-orm/node-postgres").NodePgDatabase<Record<string, never>>;
214
- type: "pg";
215
- schema: Record<string, AnyPgTable<{}> | import("drizzle-orm").Relations<string, Record<string, import("drizzle-orm").Relation<string>>>> | undefined;
216
- } | {
217
- db: import("drizzle-orm/mysql2").MySql2Database<Record<string, never>>;
218
- type: "mysql";
219
- schema: Record<string, import("drizzle-orm/mysql-core").AnyMySqlTable<{}> | import("drizzle-orm").Relations<string, Record<string, import("drizzle-orm").Relation<string>>>> | undefined;
220
- } | {
221
- db: import("./orm-extenstions/d1-driver/driver").DrizzleD1WranglerDatabase<Record<string, never>>;
222
- type: "sqlite";
223
- schema: Record<string, import("drizzle-orm").Relations<string, Record<string, import("drizzle-orm").Relation<string>>> | import("drizzle-orm/sqlite-core").AnySQLiteTable<{}>> | undefined;
224
- } | {
225
- db: import("drizzle-orm/better-sqlite3").BetterSQLite3Database<Record<string, never>>;
226
- type: "sqlite";
227
- schema: Record<string, import("drizzle-orm").Relations<string, Record<string, import("drizzle-orm").Relation<string>>> | import("drizzle-orm/sqlite-core").AnySQLiteTable<{}>> | undefined;
228
- } | {
229
- db: import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>>;
230
- type: "sqlite";
231
- schema: Record<string, import("drizzle-orm").Relations<string, Record<string, import("drizzle-orm").Relation<string>>> | import("drizzle-orm/sqlite-core").AnySQLiteTable<{}>> | undefined;
232
- }>;
212
+ export declare const prepareFrom: (connection: DbConnection) => Promise<Record<string, any>>;