drizzle-kit 0.20.14-a183d8b → 0.20.14-c82ab68

Sign up to get free protection for your applications and to get access to all the features.
package/utils-studio.mjs CHANGED
@@ -1078,6 +1078,7 @@ var require_hanji = __commonJS({
1078
1078
  var import_hanji;
1079
1079
  var init_views = __esm({
1080
1080
  "src/cli/views.ts"() {
1081
+ "use strict";
1081
1082
  init_source();
1082
1083
  import_hanji = __toESM(require_hanji());
1083
1084
  }
@@ -1087,6 +1088,7 @@ var init_views = __esm({
1087
1088
  var originUUID;
1088
1089
  var init_global = __esm({
1089
1090
  "src/global.ts"() {
1091
+ "use strict";
1090
1092
  originUUID = "00000000-0000-0000-0000-000000000000";
1091
1093
  }
1092
1094
  });
@@ -1095,6 +1097,7 @@ var init_global = __esm({
1095
1097
  import * as glob from "glob";
1096
1098
  var init_serializer = __esm({
1097
1099
  "src/serializer/index.ts"() {
1100
+ "use strict";
1098
1101
  init_source();
1099
1102
  init_views();
1100
1103
  }
@@ -1103,6 +1106,7 @@ var init_serializer = __esm({
1103
1106
  // src/cli/validations/outputs.ts
1104
1107
  var init_outputs = __esm({
1105
1108
  "src/cli/validations/outputs.ts"() {
1109
+ "use strict";
1106
1110
  init_source();
1107
1111
  }
1108
1112
  });
@@ -1116,6 +1120,7 @@ import {
1116
1120
  uniqueKeyName
1117
1121
  } from "drizzle-orm/sqlite-core";
1118
1122
  function mapSqlToSqliteType(sqlType) {
1123
+ const lowered = sqlType.toLowerCase();
1119
1124
  if ([
1120
1125
  "int",
1121
1126
  "integer",
@@ -1127,24 +1132,27 @@ function mapSqlToSqliteType(sqlType) {
1127
1132
  "unsigned big int",
1128
1133
  "int2",
1129
1134
  "int8"
1130
- ].includes(sqlType.toLowerCase())) {
1135
+ ].some((it) => lowered.startsWith(it))) {
1131
1136
  return "integer";
1132
1137
  } else if ([
1133
1138
  "character",
1134
1139
  "varchar",
1135
- "vatying character",
1140
+ "varying character",
1141
+ "national varying character",
1136
1142
  "nchar",
1137
1143
  "native character",
1138
1144
  "nvarchar",
1139
1145
  "text",
1140
1146
  "clob"
1141
- ].some((it) => it.startsWith(sqlType.toLowerCase()))) {
1147
+ ].some((it) => lowered.startsWith(it))) {
1148
+ const match2 = lowered.match(/\d+/);
1149
+ if (match2) {
1150
+ return `text(${match2[0]})`;
1151
+ }
1142
1152
  return "text";
1143
- } else if (sqlType.toLowerCase() === "blob") {
1153
+ } else if (lowered.startsWith("blob")) {
1144
1154
  return "blob";
1145
- } else if (["real", "double", "double precision", "float"].includes(
1146
- sqlType.toLowerCase()
1147
- )) {
1155
+ } else if (["real", "double", "double precision", "float"].some((it) => lowered.startsWith(it))) {
1148
1156
  return "real";
1149
1157
  } else {
1150
1158
  return "numeric";
@@ -1153,6 +1161,7 @@ function mapSqlToSqliteType(sqlType) {
1153
1161
  var dialect, fromDatabase;
1154
1162
  var init_sqliteSerializer = __esm({
1155
1163
  "src/serializer/sqliteSerializer.ts"() {
1164
+ "use strict";
1156
1165
  init_serializer();
1157
1166
  init_outputs();
1158
1167
  init_source();
@@ -1575,6 +1584,7 @@ import { is as is2, SQL as SQL2, getTableName as getTableName2 } from "drizzle-o
1575
1584
  var dialect2, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
1576
1585
  var init_pgSerializer = __esm({
1577
1586
  "src/serializer/pgSerializer.ts"() {
1587
+ "use strict";
1578
1588
  init_serializer();
1579
1589
  init_source();
1580
1590
  init_outputs();
@@ -1915,7 +1925,7 @@ var init_pgSerializer = __esm({
1915
1925
  }
1916
1926
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
1917
1927
  return {
1918
- version: "5",
1928
+ version: "6",
1919
1929
  dialect: "pg",
1920
1930
  tables: result,
1921
1931
  enums: enumsToReturn,
@@ -1987,11 +1997,369 @@ var init_pgSerializer = __esm({
1987
1997
  }
1988
1998
  });
1989
1999
 
2000
+ // node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js
2001
+ var require_pluralize = __commonJS({
2002
+ "node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js"(exports, module) {
2003
+ (function(root, pluralize) {
2004
+ if (typeof __require === "function" && typeof exports === "object" && typeof module === "object") {
2005
+ module.exports = pluralize();
2006
+ } else if (typeof define === "function" && define.amd) {
2007
+ define(function() {
2008
+ return pluralize();
2009
+ });
2010
+ } else {
2011
+ root.pluralize = pluralize();
2012
+ }
2013
+ })(exports, function() {
2014
+ var pluralRules = [];
2015
+ var singularRules = [];
2016
+ var uncountables = {};
2017
+ var irregularPlurals = {};
2018
+ var irregularSingles = {};
2019
+ function sanitizeRule(rule) {
2020
+ if (typeof rule === "string") {
2021
+ return new RegExp("^" + rule + "$", "i");
2022
+ }
2023
+ return rule;
2024
+ }
2025
+ function restoreCase(word, token) {
2026
+ if (word === token)
2027
+ return token;
2028
+ if (word === word.toLowerCase())
2029
+ return token.toLowerCase();
2030
+ if (word === word.toUpperCase())
2031
+ return token.toUpperCase();
2032
+ if (word[0] === word[0].toUpperCase()) {
2033
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
2034
+ }
2035
+ return token.toLowerCase();
2036
+ }
2037
+ function interpolate(str, args) {
2038
+ return str.replace(/\$(\d{1,2})/g, function(match2, index) {
2039
+ return args[index] || "";
2040
+ });
2041
+ }
2042
+ function replace(word, rule) {
2043
+ return word.replace(rule[0], function(match2, index) {
2044
+ var result = interpolate(rule[1], arguments);
2045
+ if (match2 === "") {
2046
+ return restoreCase(word[index - 1], result);
2047
+ }
2048
+ return restoreCase(match2, result);
2049
+ });
2050
+ }
2051
+ function sanitizeWord(token, word, rules) {
2052
+ if (!token.length || uncountables.hasOwnProperty(token)) {
2053
+ return word;
2054
+ }
2055
+ var len = rules.length;
2056
+ while (len--) {
2057
+ var rule = rules[len];
2058
+ if (rule[0].test(word))
2059
+ return replace(word, rule);
2060
+ }
2061
+ return word;
2062
+ }
2063
+ function replaceWord(replaceMap, keepMap, rules) {
2064
+ return function(word) {
2065
+ var token = word.toLowerCase();
2066
+ if (keepMap.hasOwnProperty(token)) {
2067
+ return restoreCase(word, token);
2068
+ }
2069
+ if (replaceMap.hasOwnProperty(token)) {
2070
+ return restoreCase(word, replaceMap[token]);
2071
+ }
2072
+ return sanitizeWord(token, word, rules);
2073
+ };
2074
+ }
2075
+ function checkWord(replaceMap, keepMap, rules, bool) {
2076
+ return function(word) {
2077
+ var token = word.toLowerCase();
2078
+ if (keepMap.hasOwnProperty(token))
2079
+ return true;
2080
+ if (replaceMap.hasOwnProperty(token))
2081
+ return false;
2082
+ return sanitizeWord(token, token, rules) === token;
2083
+ };
2084
+ }
2085
+ function pluralize(word, count, inclusive) {
2086
+ var pluralized = count === 1 ? pluralize.singular(word) : pluralize.plural(word);
2087
+ return (inclusive ? count + " " : "") + pluralized;
2088
+ }
2089
+ pluralize.plural = replaceWord(
2090
+ irregularSingles,
2091
+ irregularPlurals,
2092
+ pluralRules
2093
+ );
2094
+ pluralize.isPlural = checkWord(
2095
+ irregularSingles,
2096
+ irregularPlurals,
2097
+ pluralRules
2098
+ );
2099
+ pluralize.singular = replaceWord(
2100
+ irregularPlurals,
2101
+ irregularSingles,
2102
+ singularRules
2103
+ );
2104
+ pluralize.isSingular = checkWord(
2105
+ irregularPlurals,
2106
+ irregularSingles,
2107
+ singularRules
2108
+ );
2109
+ pluralize.addPluralRule = function(rule, replacement) {
2110
+ pluralRules.push([sanitizeRule(rule), replacement]);
2111
+ };
2112
+ pluralize.addSingularRule = function(rule, replacement) {
2113
+ singularRules.push([sanitizeRule(rule), replacement]);
2114
+ };
2115
+ pluralize.addUncountableRule = function(word) {
2116
+ if (typeof word === "string") {
2117
+ uncountables[word.toLowerCase()] = true;
2118
+ return;
2119
+ }
2120
+ pluralize.addPluralRule(word, "$0");
2121
+ pluralize.addSingularRule(word, "$0");
2122
+ };
2123
+ pluralize.addIrregularRule = function(single, plural2) {
2124
+ plural2 = plural2.toLowerCase();
2125
+ single = single.toLowerCase();
2126
+ irregularSingles[single] = plural2;
2127
+ irregularPlurals[plural2] = single;
2128
+ };
2129
+ [
2130
+ // Pronouns.
2131
+ ["I", "we"],
2132
+ ["me", "us"],
2133
+ ["he", "they"],
2134
+ ["she", "they"],
2135
+ ["them", "them"],
2136
+ ["myself", "ourselves"],
2137
+ ["yourself", "yourselves"],
2138
+ ["itself", "themselves"],
2139
+ ["herself", "themselves"],
2140
+ ["himself", "themselves"],
2141
+ ["themself", "themselves"],
2142
+ ["is", "are"],
2143
+ ["was", "were"],
2144
+ ["has", "have"],
2145
+ ["this", "these"],
2146
+ ["that", "those"],
2147
+ // Words ending in with a consonant and `o`.
2148
+ ["echo", "echoes"],
2149
+ ["dingo", "dingoes"],
2150
+ ["volcano", "volcanoes"],
2151
+ ["tornado", "tornadoes"],
2152
+ ["torpedo", "torpedoes"],
2153
+ // Ends with `us`.
2154
+ ["genus", "genera"],
2155
+ ["viscus", "viscera"],
2156
+ // Ends with `ma`.
2157
+ ["stigma", "stigmata"],
2158
+ ["stoma", "stomata"],
2159
+ ["dogma", "dogmata"],
2160
+ ["lemma", "lemmata"],
2161
+ ["schema", "schemata"],
2162
+ ["anathema", "anathemata"],
2163
+ // Other irregular rules.
2164
+ ["ox", "oxen"],
2165
+ ["axe", "axes"],
2166
+ ["die", "dice"],
2167
+ ["yes", "yeses"],
2168
+ ["foot", "feet"],
2169
+ ["eave", "eaves"],
2170
+ ["goose", "geese"],
2171
+ ["tooth", "teeth"],
2172
+ ["quiz", "quizzes"],
2173
+ ["human", "humans"],
2174
+ ["proof", "proofs"],
2175
+ ["carve", "carves"],
2176
+ ["valve", "valves"],
2177
+ ["looey", "looies"],
2178
+ ["thief", "thieves"],
2179
+ ["groove", "grooves"],
2180
+ ["pickaxe", "pickaxes"],
2181
+ ["passerby", "passersby"]
2182
+ ].forEach(function(rule) {
2183
+ return pluralize.addIrregularRule(rule[0], rule[1]);
2184
+ });
2185
+ [
2186
+ [/s?$/i, "s"],
2187
+ [/[^\u0000-\u007F]$/i, "$0"],
2188
+ [/([^aeiou]ese)$/i, "$1"],
2189
+ [/(ax|test)is$/i, "$1es"],
2190
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
2191
+ [/(e[mn]u)s?$/i, "$1s"],
2192
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
2193
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
2194
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
2195
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
2196
+ [/(her|at|gr)o$/i, "$1oes"],
2197
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
2198
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
2199
+ [/sis$/i, "ses"],
2200
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
2201
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
2202
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
2203
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
2204
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
2205
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
2206
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
2207
+ [/(child)(?:ren)?$/i, "$1ren"],
2208
+ [/eaux$/i, "$0"],
2209
+ [/m[ae]n$/i, "men"],
2210
+ ["thou", "you"]
2211
+ ].forEach(function(rule) {
2212
+ return pluralize.addPluralRule(rule[0], rule[1]);
2213
+ });
2214
+ [
2215
+ [/s$/i, ""],
2216
+ [/(ss)$/i, "$1"],
2217
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
2218
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
2219
+ [/ies$/i, "y"],
2220
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
2221
+ [/\b(mon|smil)ies$/i, "$1ey"],
2222
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
2223
+ [/(seraph|cherub)im$/i, "$1"],
2224
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
2225
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
2226
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
2227
+ [/(test)(?:is|es)$/i, "$1is"],
2228
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
2229
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
2230
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
2231
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
2232
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
2233
+ [/(matr|append)ices$/i, "$1ix"],
2234
+ [/(pe)(rson|ople)$/i, "$1rson"],
2235
+ [/(child)ren$/i, "$1"],
2236
+ [/(eau)x?$/i, "$1"],
2237
+ [/men$/i, "man"]
2238
+ ].forEach(function(rule) {
2239
+ return pluralize.addSingularRule(rule[0], rule[1]);
2240
+ });
2241
+ [
2242
+ // Singular words with no plurals.
2243
+ "adulthood",
2244
+ "advice",
2245
+ "agenda",
2246
+ "aid",
2247
+ "aircraft",
2248
+ "alcohol",
2249
+ "ammo",
2250
+ "analytics",
2251
+ "anime",
2252
+ "athletics",
2253
+ "audio",
2254
+ "bison",
2255
+ "blood",
2256
+ "bream",
2257
+ "buffalo",
2258
+ "butter",
2259
+ "carp",
2260
+ "cash",
2261
+ "chassis",
2262
+ "chess",
2263
+ "clothing",
2264
+ "cod",
2265
+ "commerce",
2266
+ "cooperation",
2267
+ "corps",
2268
+ "debris",
2269
+ "diabetes",
2270
+ "digestion",
2271
+ "elk",
2272
+ "energy",
2273
+ "equipment",
2274
+ "excretion",
2275
+ "expertise",
2276
+ "firmware",
2277
+ "flounder",
2278
+ "fun",
2279
+ "gallows",
2280
+ "garbage",
2281
+ "graffiti",
2282
+ "hardware",
2283
+ "headquarters",
2284
+ "health",
2285
+ "herpes",
2286
+ "highjinks",
2287
+ "homework",
2288
+ "housework",
2289
+ "information",
2290
+ "jeans",
2291
+ "justice",
2292
+ "kudos",
2293
+ "labour",
2294
+ "literature",
2295
+ "machinery",
2296
+ "mackerel",
2297
+ "mail",
2298
+ "media",
2299
+ "mews",
2300
+ "moose",
2301
+ "music",
2302
+ "mud",
2303
+ "manga",
2304
+ "news",
2305
+ "only",
2306
+ "personnel",
2307
+ "pike",
2308
+ "plankton",
2309
+ "pliers",
2310
+ "police",
2311
+ "pollution",
2312
+ "premises",
2313
+ "rain",
2314
+ "research",
2315
+ "rice",
2316
+ "salmon",
2317
+ "scissors",
2318
+ "series",
2319
+ "sewage",
2320
+ "shambles",
2321
+ "shrimp",
2322
+ "software",
2323
+ "species",
2324
+ "staff",
2325
+ "swine",
2326
+ "tennis",
2327
+ "traffic",
2328
+ "transportation",
2329
+ "trout",
2330
+ "tuna",
2331
+ "wealth",
2332
+ "welfare",
2333
+ "whiting",
2334
+ "wildebeest",
2335
+ "wildlife",
2336
+ "you",
2337
+ /pok[eé]mon$/i,
2338
+ // Regexes.
2339
+ /[^aeiou]ese$/i,
2340
+ // "chinese", "japanese"
2341
+ /deer$/i,
2342
+ // "deer", "reindeer"
2343
+ /fish$/i,
2344
+ // "fish", "blowfish", "angelfish"
2345
+ /measles$/i,
2346
+ /o[iu]s$/i,
2347
+ // "carnivorous"
2348
+ /pox$/i,
2349
+ // "chickpox", "smallpox"
2350
+ /sheep$/i
2351
+ ].forEach(pluralize.addUncountableRule);
2352
+ return pluralize;
2353
+ });
2354
+ }
2355
+ });
2356
+
1990
2357
  // src/drivers/index.ts
1991
2358
  import { sql } from "drizzle-orm";
1992
2359
  var DrizzleDbClient, DrizzleORMPgClient, TursoSqlite;
1993
2360
  var init_drivers = __esm({
1994
2361
  "src/drivers/index.ts"() {
2362
+ "use strict";
1995
2363
  DrizzleDbClient = class {
1996
2364
  constructor(db) {
1997
2365
  this.db = db;
@@ -2310,7 +2678,7 @@ String.prototype.camelCase = function() {
2310
2678
  return camelCase(String(this));
2311
2679
  };
2312
2680
  String.prototype.concatIf = function(it, condition) {
2313
- return condition ? `${this}${it}` : this;
2681
+ return condition ? `${this}${it}` : String(this);
2314
2682
  };
2315
2683
  Array.prototype.random = function() {
2316
2684
  return this[~~(Math.random() * this.length)];
@@ -3389,6 +3757,7 @@ init_views();
3389
3757
  init_pgSerializer();
3390
3758
 
3391
3759
  // src/introspect-pg.ts
3760
+ var import_pluralize = __toESM(require_pluralize());
3392
3761
  import { getTableName as getTableName3, is as is3 } from "drizzle-orm";
3393
3762
  import {
3394
3763
  createTableRelationsHelpers,
package/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Dialect } from "./schemaValidator";
2
2
  import { NamedWithSchema } from "./cli/commands/migrate";
3
- export declare const assertV1OutFolder: (out: string, dialect: Dialect | "{dialect}") => void;
3
+ export declare const assertV1OutFolder: (out: string) => void;
4
4
  export type Journal = {
5
5
  version: string;
6
6
  dialect: Dialect;
@@ -50,9 +50,9 @@ export declare const prepareMigrationMeta: (schemas: {
50
50
  column: string;
51
51
  };
52
52
  }[]) => {
53
- schemas: {};
54
- tables: {};
55
- columns: {};
53
+ schemas: Record<string, string>;
54
+ tables: Record<string, string>;
55
+ columns: Record<string, string>;
56
56
  };
57
57
  export declare const schemaRenameKey: (it: string) => string;
58
58
  export declare const tableRenameKey: (it: NamedWithSchema) => string;
@@ -73,10 +73,6 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
73
73
  } | undefined>;
74
74
  } | undefined>;
75
75
  } | undefined;
76
- id: string;
77
- prevId: string;
78
- version: "5";
79
- dialect: "pg";
80
76
  tables: Record<string, {
81
77
  name: string;
82
78
  columns: Record<string, {
@@ -115,6 +111,10 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
115
111
  nullsNotDistinct: boolean;
116
112
  }>;
117
113
  }>;
114
+ id: string;
115
+ prevId: string;
116
+ version: "6";
117
+ dialect: "pg";
118
118
  schemas: Record<string, string>;
119
119
  _meta: {
120
120
  columns: Record<string, string>;
@@ -136,10 +136,6 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
136
136
  } | undefined>;
137
137
  } | undefined>;
138
138
  } | undefined;
139
- id: string;
140
- prevId: string;
141
- version: "5";
142
- dialect: "pg";
143
139
  tables: Record<string, {
144
140
  name: string;
145
141
  columns: Record<string, {
@@ -178,6 +174,10 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
178
174
  nullsNotDistinct: boolean;
179
175
  }>;
180
176
  }>;
177
+ id: string;
178
+ prevId: string;
179
+ version: "6";
180
+ dialect: "pg";
181
181
  schemas: Record<string, string>;
182
182
  _meta: {
183
183
  columns: Record<string, string>;