drizzle-kit 0.24.2-56454b7 → 0.24.2-5b9600e

Sign up to get free protection for your applications and to get access to all the features.
Files changed (10) hide show
  1. package/api.d.mts +6 -6
  2. package/api.d.ts +6 -6
  3. package/api.js +90160 -14028
  4. package/api.mjs +90158 -14028
  5. package/bin.cjs +34928 -34778
  6. package/index.d.mts +3 -0
  7. package/index.d.ts +3 -0
  8. package/package.json +2 -2
  9. package/utils.js +33 -17
  10. package/utils.mjs +32 -17
package/index.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { ConnectionOptions } from 'tls';
2
2
 
3
+ declare const prefixes: readonly ["index", "timestamp", "supabase", "unix", "none"];
4
+ type Prefix = (typeof prefixes)[number];
3
5
  declare const drivers: readonly ["turso", "d1-http", "expo", "aws-data-api", "pglite"];
4
6
  type Driver = (typeof drivers)[number];
5
7
 
@@ -120,6 +122,7 @@ type Config = {
120
122
  migrations?: {
121
123
  table?: string;
122
124
  schema?: string;
125
+ prefix?: Prefix;
123
126
  };
124
127
  introspect?: {
125
128
  casing: 'camel' | 'preserve';
package/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { ConnectionOptions } from 'tls';
2
2
 
3
+ declare const prefixes: readonly ["index", "timestamp", "supabase", "unix", "none"];
4
+ type Prefix = (typeof prefixes)[number];
3
5
  declare const drivers: readonly ["turso", "d1-http", "expo", "aws-data-api", "pglite"];
4
6
  type Driver = (typeof drivers)[number];
5
7
 
@@ -120,6 +122,7 @@ type Config = {
120
122
  migrations?: {
121
123
  table?: string;
122
124
  schema?: string;
125
+ prefix?: Prefix;
123
126
  };
124
127
  introspect?: {
125
128
  casing: 'camel' | 'preserve';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.24.2-56454b7",
3
+ "version": "0.24.2-5b9600e",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",
@@ -39,7 +39,6 @@
39
39
  "build:dev": "rm -rf ./dist && tsx build.dev.ts && tsc -p tsconfig.cli-types.json && chmod +x ./dist/index.cjs",
40
40
  "pack": "cp package.json README.md dist/ && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz",
41
41
  "tsc": "tsc -p tsconfig.build.json",
42
- "types": "tsc --noEmit",
43
42
  "publish": "npm publish package.tgz"
44
43
  },
45
44
  "dependencies": {
@@ -75,6 +74,7 @@
75
74
  "@vercel/postgres": "^0.8.0",
76
75
  "ava": "^5.1.0",
77
76
  "better-sqlite3": "^9.4.3",
77
+ "bun-types": "^0.6.6",
78
78
  "camelcase": "^7.0.1",
79
79
  "chalk": "^5.2.0",
80
80
  "commander": "^12.1.0",
package/utils.js CHANGED
@@ -564,9 +564,10 @@ var require_hanji = __commonJS({
564
564
  // src/utils.ts
565
565
  var utils_exports = {};
566
566
  __export(utils_exports, {
567
- assertV3OutFolder: () => assertV3OutFolder,
567
+ assertV1OutFolder: () => assertV1OutFolder,
568
568
  columnRenameKey: () => columnRenameKey,
569
569
  copy: () => copy,
570
+ dryJournal: () => dryJournal,
570
571
  isPgArrayType: () => isPgArrayType,
571
572
  kloudMeta: () => kloudMeta,
572
573
  normalisePGliteUrl: () => normalisePGliteUrl,
@@ -5555,25 +5556,39 @@ var copy = (it) => {
5555
5556
  var objectValues = (obj) => {
5556
5557
  return Object.values(obj);
5557
5558
  };
5558
- var assertV3OutFolder = (out) => {
5559
+ var assertV1OutFolder = (out) => {
5559
5560
  if (!(0, import_fs.existsSync)(out))
5560
5561
  return;
5561
- if (!(0, import_fs.existsSync)((0, import_path.join)(out, "meta")))
5562
- return;
5563
- console.log(
5564
- `Your migrations folder format is outdated, please run ${source_default.green.bold(
5565
- `drizzle-kit up`
5566
- )}`
5562
+ const oldMigrationFolders = (0, import_fs.readdirSync)(out).filter(
5563
+ (it) => it.length === 14 && /^\d+$/.test(it)
5567
5564
  );
5568
- process.exit(1);
5565
+ if (oldMigrationFolders.length > 0) {
5566
+ console.log(
5567
+ `Your migrations folder format is outdated, please run ${source_default.green.bold(
5568
+ `drizzle-kit up`
5569
+ )}`
5570
+ );
5571
+ process.exit(1);
5572
+ }
5573
+ };
5574
+ var dryJournal = (dialect3) => {
5575
+ return {
5576
+ version: snapshotVersion,
5577
+ dialect: dialect3,
5578
+ entries: []
5579
+ };
5569
5580
  };
5570
5581
  var prepareOutFolder = (out, dialect3) => {
5571
- (0, import_fs.mkdirSync)(out, { recursive: true });
5572
- const snapshots = (0, import_fs.readdirSync)(out).filter((it) => (0, import_fs.lstatSync)((0, import_path.join)(out, it)).isDirectory()).map(
5573
- (it) => (0, import_path.join)(out, it, "snapshot.json")
5574
- );
5582
+ const meta = (0, import_path.join)(out, "meta");
5583
+ const journalPath = (0, import_path.join)(meta, "_journal.json");
5584
+ if (!(0, import_fs.existsSync)((0, import_path.join)(out, "meta"))) {
5585
+ (0, import_fs.mkdirSync)(meta, { recursive: true });
5586
+ (0, import_fs.writeFileSync)(journalPath, JSON.stringify(dryJournal(dialect3)));
5587
+ }
5588
+ const journal = JSON.parse((0, import_fs.readFileSync)(journalPath).toString());
5589
+ const snapshots = (0, import_fs.readdirSync)(meta).filter((it) => !it.startsWith("_")).map((it) => (0, import_path.join)(meta, it));
5575
5590
  snapshots.sort();
5576
- return snapshots;
5591
+ return { meta, snapshots, journal };
5577
5592
  };
5578
5593
  var validatorForDialect = (dialect3) => {
5579
5594
  switch (dialect3) {
@@ -5628,7 +5643,7 @@ var validateWithReport = (snapshots, dialect3) => {
5628
5643
  return result;
5629
5644
  };
5630
5645
  var prepareMigrationFolder = (outFolder = "drizzle", dialect3) => {
5631
- const snapshots = prepareOutFolder(outFolder, dialect3);
5646
+ const { snapshots, journal } = prepareOutFolder(outFolder, dialect3);
5632
5647
  const report = validateWithReport(snapshots, dialect3);
5633
5648
  if (report.nonLatest.length > 0) {
5634
5649
  console.log(
@@ -5660,7 +5675,7 @@ var prepareMigrationFolder = (outFolder = "drizzle", dialect3) => {
5660
5675
  if (abort) {
5661
5676
  process.exit(0);
5662
5677
  }
5663
- return snapshots;
5678
+ return { snapshots, journal };
5664
5679
  };
5665
5680
  var prepareMigrationMeta = (schemas, tables, columns) => {
5666
5681
  const _meta = {
@@ -5737,9 +5752,10 @@ function isPgArrayType(sqlType) {
5737
5752
  }
5738
5753
  // Annotate the CommonJS export names for ESM import in node:
5739
5754
  0 && (module.exports = {
5740
- assertV3OutFolder,
5755
+ assertV1OutFolder,
5741
5756
  columnRenameKey,
5742
5757
  copy,
5758
+ dryJournal,
5743
5759
  isPgArrayType,
5744
5760
  kloudMeta,
5745
5761
  normalisePGliteUrl,
package/utils.mjs CHANGED
@@ -1052,7 +1052,7 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
1052
1052
  var source_default = chalk;
1053
1053
 
1054
1054
  // src/utils.ts
1055
- import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync } from "fs";
1055
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";
1056
1056
  import { join } from "path";
1057
1057
  import { parse } from "url";
1058
1058
 
@@ -5536,25 +5536,39 @@ var copy = (it) => {
5536
5536
  var objectValues = (obj) => {
5537
5537
  return Object.values(obj);
5538
5538
  };
5539
- var assertV3OutFolder = (out) => {
5539
+ var assertV1OutFolder = (out) => {
5540
5540
  if (!existsSync(out))
5541
5541
  return;
5542
- if (!existsSync(join(out, "meta")))
5543
- return;
5544
- console.log(
5545
- `Your migrations folder format is outdated, please run ${source_default.green.bold(
5546
- `drizzle-kit up`
5547
- )}`
5542
+ const oldMigrationFolders = readdirSync(out).filter(
5543
+ (it) => it.length === 14 && /^\d+$/.test(it)
5548
5544
  );
5549
- process.exit(1);
5545
+ if (oldMigrationFolders.length > 0) {
5546
+ console.log(
5547
+ `Your migrations folder format is outdated, please run ${source_default.green.bold(
5548
+ `drizzle-kit up`
5549
+ )}`
5550
+ );
5551
+ process.exit(1);
5552
+ }
5553
+ };
5554
+ var dryJournal = (dialect3) => {
5555
+ return {
5556
+ version: snapshotVersion,
5557
+ dialect: dialect3,
5558
+ entries: []
5559
+ };
5550
5560
  };
5551
5561
  var prepareOutFolder = (out, dialect3) => {
5552
- mkdirSync(out, { recursive: true });
5553
- const snapshots = readdirSync(out).filter((it) => lstatSync(join(out, it)).isDirectory()).map(
5554
- (it) => join(out, it, "snapshot.json")
5555
- );
5562
+ const meta = join(out, "meta");
5563
+ const journalPath = join(meta, "_journal.json");
5564
+ if (!existsSync(join(out, "meta"))) {
5565
+ mkdirSync(meta, { recursive: true });
5566
+ writeFileSync(journalPath, JSON.stringify(dryJournal(dialect3)));
5567
+ }
5568
+ const journal = JSON.parse(readFileSync(journalPath).toString());
5569
+ const snapshots = readdirSync(meta).filter((it) => !it.startsWith("_")).map((it) => join(meta, it));
5556
5570
  snapshots.sort();
5557
- return snapshots;
5571
+ return { meta, snapshots, journal };
5558
5572
  };
5559
5573
  var validatorForDialect = (dialect3) => {
5560
5574
  switch (dialect3) {
@@ -5609,7 +5623,7 @@ var validateWithReport = (snapshots, dialect3) => {
5609
5623
  return result;
5610
5624
  };
5611
5625
  var prepareMigrationFolder = (outFolder = "drizzle", dialect3) => {
5612
- const snapshots = prepareOutFolder(outFolder, dialect3);
5626
+ const { snapshots, journal } = prepareOutFolder(outFolder, dialect3);
5613
5627
  const report = validateWithReport(snapshots, dialect3);
5614
5628
  if (report.nonLatest.length > 0) {
5615
5629
  console.log(
@@ -5641,7 +5655,7 @@ var prepareMigrationFolder = (outFolder = "drizzle", dialect3) => {
5641
5655
  if (abort) {
5642
5656
  process.exit(0);
5643
5657
  }
5644
- return snapshots;
5658
+ return { snapshots, journal };
5645
5659
  };
5646
5660
  var prepareMigrationMeta = (schemas, tables, columns) => {
5647
5661
  const _meta = {
@@ -5717,9 +5731,10 @@ function isPgArrayType(sqlType) {
5717
5731
  return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
5718
5732
  }
5719
5733
  export {
5720
- assertV3OutFolder,
5734
+ assertV1OutFolder,
5721
5735
  columnRenameKey,
5722
5736
  copy,
5737
+ dryJournal,
5723
5738
  isPgArrayType,
5724
5739
  kloudMeta,
5725
5740
  normalisePGliteUrl,