drizzle-kit 0.19.8 → 0.19.9-cc05443

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. package/index.cjs +13478 -13004
  2. package/index.d.ts +1 -0
  3. package/loader.mjs +25 -15
  4. package/package.json +3 -2
  5. package/utils.js +16 -3
package/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export type Config = {
2
2
  out?: string | undefined;
3
3
  breakpoints?: boolean | undefined;
4
4
  tablesFilter?: string | string[] | undefined;
5
+ schemaFilter?: string | string[] | undefined;
5
6
  schema?: string | string[];
6
7
  verbose?: boolean | undefined;
7
8
  strict?: boolean | undefined;
package/loader.mjs CHANGED
@@ -2,34 +2,44 @@ import esbuild from "esbuild";
2
2
  import * as path from "path";
3
3
  import { readFileSync } from "fs";
4
4
 
5
+ const parse = (it) => {
6
+ if (!it) return { drizzle: false };
7
+
8
+ if (it.endsWith("__drizzle__")) {
9
+ const offset = it.startsWith("file://") ? "file://".length : 0;
10
+ const clean = it.slice(offset, -"__drizzle__".length);
11
+ return { drizzle: true, clean, original: it };
12
+ }
13
+ return { drizzle: false, clean: it };
14
+ };
15
+
5
16
  export function resolve(specifier, context, nextResolve) {
6
- if (specifier.startsWith("__drizzle__")) {
7
- if (!specifier.endsWith(".ts")) {
8
- const url = specifier.slice("__drizzle__".length).toString();
9
- return nextResolve(url);
10
- }
17
+ const { drizzle, clean } = parse(specifier);
18
+ if (drizzle && !clean.endsWith(".ts") && !clean.endsWith(".mts")) {
19
+ return nextResolve(clean);
20
+ }
11
21
 
22
+ if (drizzle) {
12
23
  return {
13
24
  shortCircuit: true,
14
- url: specifier,
25
+ url: `file://${specifier}`,
15
26
  };
16
27
  }
17
28
 
18
- const { parentURL: url } = context;
19
- const parentURL = url?.startsWith("__drizzle__")
20
- ? new URL(`file://${path.resolve(url.slice("__drizzle__".length))}`)
21
- : url;
29
+ const parsedParent = parse(context.parentURL);
30
+ const parentURL = parsedParent.drizzle
31
+ ? new URL(`file://${path.resolve(parsedParent.clean)}`)
32
+ : context.parentURL;
22
33
 
23
34
  // Let Node.js handle all other specifiers.
24
35
  return nextResolve(specifier, { ...context, parentURL });
25
36
  }
26
37
 
27
38
  export async function load(url, context, defaultLoad) {
28
- if (url.startsWith("__drizzle__")) {
29
-
30
- const path = url.slice("__drizzle__".length).trim();
31
- const file = readFileSync(path, "utf-8");
32
- if (path.endsWith(".ts") || path.endsWith(".mts")) {
39
+ const { drizzle, clean } = parse(url);
40
+ if (drizzle) {
41
+ const file = readFileSync(clean, "utf-8");
42
+ if (clean.endsWith(".ts") || clean.endsWith(".mts")) {
33
43
  const source = esbuild.transformSync(file, {
34
44
  loader: "ts",
35
45
  format: "esm",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.19.8",
3
+ "version": "0.19.9-cc05443",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
@@ -8,10 +8,11 @@
8
8
  "drizzle-kit": "./index.cjs"
9
9
  },
10
10
  "scripts": {
11
+ "test:pg:push": "drizzle-kit push:pg",
11
12
  "migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
12
13
  "push": "node -r esbuild-register ./src/cli/index.ts push:mysql",
13
14
  "push:sqlite": "node -r ./src/loader.mjs ./src/cli/index.ts push:sqlite",
14
- "try1": "tsx ./dev/test.ts",
15
+ "try1": "tsx ./src/t.ts",
15
16
  "migrate:old:mysql": "drizzle-kit generate:mysql --out ./dev/migrations-mysql --schema ./dev/migrations-mysql/schema.ts",
16
17
  "start:pg": "node -r esbuild-register ./src/cli/index.ts generate:pg",
17
18
  "start:sqlite": "node -r esbuild-register ./src/cli/index.ts generate:sqlite",
package/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env -S node --loader @esbuild-kit/esm-loader --no-warnings
1
+ #!/usr/bin/env node --loader @esbuild-kit/esm-loader --no-warnings
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -13056,6 +13056,18 @@ var pgSchemaInternalV4 = objectType({
13056
13056
  enums: recordType(stringType(), enumSchema),
13057
13057
  schemas: recordType(stringType(), stringType())
13058
13058
  }).strict();
13059
+ var pgSchemaExternal = objectType({
13060
+ version: literalType("5"),
13061
+ dialect: literalType("pg"),
13062
+ tables: arrayType(table2),
13063
+ enums: arrayType(enumSchema),
13064
+ schemas: arrayType(objectType({ name: stringType() })),
13065
+ _meta: objectType({
13066
+ schemas: recordType(stringType(), stringType()),
13067
+ tables: recordType(stringType(), stringType()),
13068
+ columns: recordType(stringType(), stringType())
13069
+ })
13070
+ }).strict();
13059
13071
  var pgSchemaInternal = objectType({
13060
13072
  version: literalType("5"),
13061
13073
  dialect: literalType("pg"),
@@ -15195,7 +15207,8 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
15195
15207
  ////
15196
15208
  type: "alter_table_alter_column_drop_pk",
15197
15209
  tableName,
15198
- columnName
15210
+ columnName,
15211
+ schema: schema4
15199
15212
  });
15200
15213
  }
15201
15214
  if (((_g = column4.default) == null ? void 0 : _g.type) === "added") {
@@ -16067,12 +16080,12 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
16067
16080
  });
16068
16081
  jsonStatements.push(...jsonMySqlCreateTables);
16069
16082
  }
16083
+ jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
16070
16084
  jsonStatements.push(...jsonDropTables);
16071
16085
  jsonStatements.push(...jsonRenameTables);
16072
16086
  jsonStatements.push(...jsonRenameColumnsStatements);
16073
16087
  jsonStatements.push(...jsonDeletedCompositePKs);
16074
16088
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16075
- jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
16076
16089
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
16077
16090
  jsonStatements.push(...jsonTableAlternations.alterColumns);
16078
16091
  jsonStatements.push(...jsonTableAlternations.createColumns);