drizzle-seed 0.3.1-dc3b366 → 0.3.1-dfa4db3
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.cjs +35 -39
- package/index.cjs.map +1 -1
- package/index.d.cts +9 -9
- package/index.d.mts +9 -9
- package/index.d.ts +9 -9
- package/index.mjs +27 -31
- package/index.mjs.map +1 -1
- package/package.json +6 -6
- package/services/SeedService.d.cts +4 -4
- package/services/SeedService.d.mts +4 -4
- package/services/SeedService.d.ts +4 -4
package/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var drizzleOrm = require('drizzle-orm');
|
|
4
|
+
var _relations = require('drizzle-orm/_relations');
|
|
4
5
|
var mysqlCore = require('drizzle-orm/mysql-core');
|
|
5
6
|
var pgCore = require('drizzle-orm/pg-core');
|
|
6
7
|
var sqliteCore = require('drizzle-orm/sqlite-core');
|
|
@@ -133097,7 +133098,7 @@ class GeneratePoint extends AbstractGenerator {
|
|
|
133097
133098
|
}
|
|
133098
133099
|
const x = this.state.xCoordinateGen.generate();
|
|
133099
133100
|
const y = this.state.yCoordinateGen.generate();
|
|
133100
|
-
if (this.dataType === '
|
|
133101
|
+
if (this.dataType === 'object') {
|
|
133101
133102
|
return { x, y };
|
|
133102
133103
|
}
|
|
133103
133104
|
else if (this.dataType === 'string') {
|
|
@@ -133134,7 +133135,7 @@ class GenerateUniquePoint extends AbstractGenerator {
|
|
|
133134
133135
|
}
|
|
133135
133136
|
const x = this.state.xCoordinateGen.generate();
|
|
133136
133137
|
const y = this.state.yCoordinateGen.generate();
|
|
133137
|
-
if (this.dataType === '
|
|
133138
|
+
if (this.dataType === 'object') {
|
|
133138
133139
|
return { x, y };
|
|
133139
133140
|
}
|
|
133140
133141
|
else if (this.dataType === 'string') {
|
|
@@ -133183,7 +133184,7 @@ class GenerateLine extends AbstractGenerator {
|
|
|
133183
133184
|
b = this.state.bCoefficientGen.generate();
|
|
133184
133185
|
}
|
|
133185
133186
|
const c = this.state.cCoefficientGen.generate();
|
|
133186
|
-
if (this.dataType === '
|
|
133187
|
+
if (this.dataType === 'object') {
|
|
133187
133188
|
return { a, b, c };
|
|
133188
133189
|
}
|
|
133189
133190
|
else if (this.dataType === 'string') {
|
|
@@ -133231,7 +133232,7 @@ class GenerateUniqueLine extends AbstractGenerator {
|
|
|
133231
133232
|
b = this.state.bCoefficientGen.generate();
|
|
133232
133233
|
}
|
|
133233
133234
|
const c = this.state.cCoefficientGen.generate();
|
|
133234
|
-
if (this.dataType === '
|
|
133235
|
+
if (this.dataType === 'object') {
|
|
133235
133236
|
return { a, b, c };
|
|
133236
133237
|
}
|
|
133237
133238
|
else if (this.dataType === 'string') {
|
|
@@ -134945,7 +134946,7 @@ class SeedService {
|
|
|
134945
134946
|
const generator = new generatorsMap.GenerateBoolean[0]();
|
|
134946
134947
|
return generator;
|
|
134947
134948
|
}
|
|
134948
|
-
if ((col.columnType === 'integer' && col.dataType === '
|
|
134949
|
+
if ((col.columnType === 'integer' && col.dataType === 'object')) {
|
|
134949
134950
|
const generator = new generatorsMap.GenerateTimestamp[0]();
|
|
134950
134951
|
return generator;
|
|
134951
134952
|
}
|
|
@@ -135214,7 +135215,7 @@ class SeedService {
|
|
|
135214
135215
|
maxParametersNumber = this.mysqlMaxParametersNumber;
|
|
135215
135216
|
}
|
|
135216
135217
|
else {
|
|
135217
|
-
// is(db, BaseSQLiteDatabase<any, any>)
|
|
135218
|
+
// is(db, BaseSQLiteDatabase<any, any, any, any, any ,any>)
|
|
135218
135219
|
maxParametersNumber = this.sqliteMaxParametersNumber;
|
|
135219
135220
|
}
|
|
135220
135221
|
const maxBatchSize = Math.floor(maxParametersNumber / columnsNumber);
|
|
@@ -135539,7 +135540,7 @@ const resetPostgres = async (db, pgTables) => {
|
|
|
135539
135540
|
await db.execute(drizzleOrm.sql.raw(`truncate ${tablesToTruncate.join(',')} cascade;`));
|
|
135540
135541
|
};
|
|
135541
135542
|
const filterPgSchema = (schema) => {
|
|
135542
|
-
const pgSchema = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], pgCore.PgTable) || drizzleOrm.is(keyValue[1],
|
|
135543
|
+
const pgSchema = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], pgCore.PgTable) || drizzleOrm.is(keyValue[1], _relations.Relations)));
|
|
135543
135544
|
const pgTables = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], pgCore.PgTable)));
|
|
135544
135545
|
return { pgSchema, pgTables };
|
|
135545
135546
|
};
|
|
@@ -135570,20 +135571,22 @@ const getPostgresInfo = (pgSchema, pgTables) => {
|
|
|
135570
135571
|
return dbToTsColumnNamesMap;
|
|
135571
135572
|
}
|
|
135572
135573
|
const tableConfig = pgCore.getTableConfig(table);
|
|
135573
|
-
for (const [tsCol, col] of Object.entries(tableConfig.columns[0]
|
|
135574
|
-
dbToTsColumnNamesMap[col.name] = tsCol;
|
|
135574
|
+
for (const [tsCol, col] of Object.entries(drizzleOrm.getColumnTable(tableConfig.columns[0]))) {
|
|
135575
|
+
// dbToTsColumnNamesMap[col.name] = tsCol;
|
|
135576
|
+
if (drizzleOrm.is(col, drizzleOrm.Column))
|
|
135577
|
+
dbToTsColumnNamesMap[col.name] = tsCol;
|
|
135575
135578
|
}
|
|
135576
135579
|
dbToTsColumnNamesMapGlobal[tableName] = dbToTsColumnNamesMap;
|
|
135577
135580
|
return dbToTsColumnNamesMap;
|
|
135578
135581
|
};
|
|
135579
135582
|
const transformFromDrizzleRelation = (schema, getDbToTsColumnNamesMap, tableRelations) => {
|
|
135580
|
-
const schemaConfig =
|
|
135583
|
+
const schemaConfig = _relations.extractTablesRelationalConfig(schema, _relations.createTableRelationsHelpers);
|
|
135581
135584
|
const relations = [];
|
|
135582
135585
|
for (const table of Object.values(schemaConfig.tables)) {
|
|
135583
135586
|
if (table.relations === undefined)
|
|
135584
135587
|
continue;
|
|
135585
135588
|
for (const drizzleRel of Object.values(table.relations)) {
|
|
135586
|
-
if (!drizzleOrm.is(drizzleRel,
|
|
135589
|
+
if (!drizzleOrm.is(drizzleRel, _relations.One))
|
|
135587
135590
|
continue;
|
|
135588
135591
|
const tableConfig = pgCore.getTableConfig(drizzleRel.sourceTable);
|
|
135589
135592
|
const tableDbSchema = tableConfig.schema ?? 'public';
|
|
@@ -135627,10 +135630,7 @@ const getPostgresInfo = (pgSchema, pgTables) => {
|
|
|
135627
135630
|
};
|
|
135628
135631
|
for (const table of Object.values(pgTables)) {
|
|
135629
135632
|
tableConfig = pgCore.getTableConfig(table);
|
|
135630
|
-
dbToTsColumnNamesMap =
|
|
135631
|
-
for (const [tsCol, col] of Object.entries(tableConfig.columns[0].table)) {
|
|
135632
|
-
dbToTsColumnNamesMap[col.name] = tsCol;
|
|
135633
|
-
}
|
|
135633
|
+
dbToTsColumnNamesMap = getDbToTsColumnNamesMap(table);
|
|
135634
135634
|
// might be empty list
|
|
135635
135635
|
const newRelations = tableConfig.foreignKeys.map((fk) => {
|
|
135636
135636
|
const table = dbToTsTableNamesMap[tableConfig.name];
|
|
@@ -135661,8 +135661,8 @@ const getPostgresInfo = (pgSchema, pgTables) => {
|
|
|
135661
135661
|
name: baseColumn.name,
|
|
135662
135662
|
columnType: baseColumn.getSQLType(),
|
|
135663
135663
|
typeParams: getTypeParams(baseColumn.getSQLType()),
|
|
135664
|
-
dataType: baseColumn.dataType,
|
|
135665
|
-
size: baseColumn.
|
|
135664
|
+
dataType: baseColumn.dataType.split(' ')[0],
|
|
135665
|
+
size: baseColumn.length,
|
|
135666
135666
|
hasDefault: baseColumn.hasDefault,
|
|
135667
135667
|
enumValues: baseColumn.enumValues,
|
|
135668
135668
|
default: baseColumn.default,
|
|
@@ -135714,8 +135714,8 @@ const getPostgresInfo = (pgSchema, pgTables) => {
|
|
|
135714
135714
|
name: dbToTsColumnNamesMap[column.name],
|
|
135715
135715
|
columnType: column.getSQLType(),
|
|
135716
135716
|
typeParams: getTypeParams(column.getSQLType()),
|
|
135717
|
-
dataType: column.dataType,
|
|
135718
|
-
size: column.
|
|
135717
|
+
dataType: column.dataType.split(' ')[0],
|
|
135718
|
+
size: column.length,
|
|
135719
135719
|
hasDefault: column.hasDefault,
|
|
135720
135720
|
default: column.default,
|
|
135721
135721
|
enumValues: column.enumValues,
|
|
@@ -135789,7 +135789,7 @@ const resetMySql = async (db, schema) => {
|
|
|
135789
135789
|
await db.execute(drizzleOrm.sql.raw('SET FOREIGN_KEY_CHECKS = 1;'));
|
|
135790
135790
|
};
|
|
135791
135791
|
const filterMysqlTables = (schema) => {
|
|
135792
|
-
const mysqlSchema = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], mysqlCore.MySqlTable) || drizzleOrm.is(keyValue[1],
|
|
135792
|
+
const mysqlSchema = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], mysqlCore.MySqlTable) || drizzleOrm.is(keyValue[1], _relations.Relations)));
|
|
135793
135793
|
const mysqlTables = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], mysqlCore.MySqlTable)));
|
|
135794
135794
|
return { mysqlSchema, mysqlTables };
|
|
135795
135795
|
};
|
|
@@ -135820,20 +135820,21 @@ const getMySqlInfo = (mysqlSchema, mysqlTables) => {
|
|
|
135820
135820
|
return dbToTsColumnNamesMap;
|
|
135821
135821
|
}
|
|
135822
135822
|
const tableConfig = mysqlCore.getTableConfig(table);
|
|
135823
|
-
for (const [tsCol, col] of Object.entries(tableConfig.columns[0]
|
|
135824
|
-
|
|
135823
|
+
for (const [tsCol, col] of Object.entries(drizzleOrm.getColumnTable(tableConfig.columns[0]))) {
|
|
135824
|
+
if (drizzleOrm.is(col, drizzleOrm.Column))
|
|
135825
|
+
dbToTsColumnNamesMap[col.name] = tsCol;
|
|
135825
135826
|
}
|
|
135826
135827
|
dbToTsColumnNamesMapGlobal[tableName] = dbToTsColumnNamesMap;
|
|
135827
135828
|
return dbToTsColumnNamesMap;
|
|
135828
135829
|
};
|
|
135829
135830
|
const transformFromDrizzleRelation = (schema, getDbToTsColumnNamesMap, tableRelations) => {
|
|
135830
|
-
const schemaConfig =
|
|
135831
|
+
const schemaConfig = _relations.extractTablesRelationalConfig(schema, _relations.createTableRelationsHelpers);
|
|
135831
135832
|
const relations = [];
|
|
135832
135833
|
for (const table of Object.values(schemaConfig.tables)) {
|
|
135833
135834
|
if (table.relations === undefined)
|
|
135834
135835
|
continue;
|
|
135835
135836
|
for (const drizzleRel of Object.values(table.relations)) {
|
|
135836
|
-
if (!drizzleOrm.is(drizzleRel,
|
|
135837
|
+
if (!drizzleOrm.is(drizzleRel, _relations.One))
|
|
135837
135838
|
continue;
|
|
135838
135839
|
const tableConfig = mysqlCore.getTableConfig(drizzleRel.sourceTable);
|
|
135839
135840
|
const tableDbSchema = tableConfig.schema ?? 'public';
|
|
@@ -135877,10 +135878,7 @@ const getMySqlInfo = (mysqlSchema, mysqlTables) => {
|
|
|
135877
135878
|
};
|
|
135878
135879
|
for (const table of Object.values(mysqlTables)) {
|
|
135879
135880
|
tableConfig = mysqlCore.getTableConfig(table);
|
|
135880
|
-
dbToTsColumnNamesMap =
|
|
135881
|
-
for (const [tsCol, col] of Object.entries(tableConfig.columns[0].table)) {
|
|
135882
|
-
dbToTsColumnNamesMap[col.name] = tsCol;
|
|
135883
|
-
}
|
|
135881
|
+
dbToTsColumnNamesMap = getDbToTsColumnNamesMap(table);
|
|
135884
135882
|
const newRelations = tableConfig.foreignKeys.map((fk) => {
|
|
135885
135883
|
const table = dbToTsTableNamesMap[tableConfig.name];
|
|
135886
135884
|
const refTable = dbToTsTableNamesMap[drizzleOrm.getTableName(fk.reference().foreignTable)];
|
|
@@ -135935,7 +135933,7 @@ const getMySqlInfo = (mysqlSchema, mysqlTables) => {
|
|
|
135935
135933
|
name: dbToTsColumnNamesMap[column.name],
|
|
135936
135934
|
columnType: column.getSQLType(),
|
|
135937
135935
|
typeParams: getTypeParams(column.getSQLType()),
|
|
135938
|
-
dataType: column.dataType,
|
|
135936
|
+
dataType: column.dataType.split(' ')[0],
|
|
135939
135937
|
hasDefault: column.hasDefault,
|
|
135940
135938
|
default: column.default,
|
|
135941
135939
|
enumValues: column.enumValues,
|
|
@@ -135975,7 +135973,7 @@ const resetSqlite = async (db, schema) => {
|
|
|
135975
135973
|
await db.run(drizzleOrm.sql.raw('PRAGMA foreign_keys = ON'));
|
|
135976
135974
|
};
|
|
135977
135975
|
const filterSqliteTables = (schema) => {
|
|
135978
|
-
const sqliteSchema = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], sqliteCore.SQLiteTable) || drizzleOrm.is(keyValue[1],
|
|
135976
|
+
const sqliteSchema = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], sqliteCore.SQLiteTable) || drizzleOrm.is(keyValue[1], _relations.Relations)));
|
|
135979
135977
|
const sqliteTables = Object.fromEntries(Object.entries(schema).filter((keyValue) => drizzleOrm.is(keyValue[1], sqliteCore.SQLiteTable)));
|
|
135980
135978
|
return { sqliteSchema, sqliteTables };
|
|
135981
135979
|
};
|
|
@@ -136006,20 +136004,21 @@ const getSqliteInfo = (sqliteSchema, sqliteTables) => {
|
|
|
136006
136004
|
return dbToTsColumnNamesMap;
|
|
136007
136005
|
}
|
|
136008
136006
|
const tableConfig = sqliteCore.getTableConfig(table);
|
|
136009
|
-
for (const [tsCol, col] of Object.entries(tableConfig.columns[0]
|
|
136010
|
-
|
|
136007
|
+
for (const [tsCol, col] of Object.entries(drizzleOrm.getColumnTable(tableConfig.columns[0]))) {
|
|
136008
|
+
if (drizzleOrm.is(col, drizzleOrm.Column))
|
|
136009
|
+
dbToTsColumnNamesMap[col.name] = tsCol;
|
|
136011
136010
|
}
|
|
136012
136011
|
dbToTsColumnNamesMapGlobal[tableName] = dbToTsColumnNamesMap;
|
|
136013
136012
|
return dbToTsColumnNamesMap;
|
|
136014
136013
|
};
|
|
136015
136014
|
const transformFromDrizzleRelation = (schema, getDbToTsColumnNamesMap, tableRelations) => {
|
|
136016
|
-
const schemaConfig =
|
|
136015
|
+
const schemaConfig = _relations.extractTablesRelationalConfig(schema, _relations.createTableRelationsHelpers);
|
|
136017
136016
|
const relations = [];
|
|
136018
136017
|
for (const table of Object.values(schemaConfig.tables)) {
|
|
136019
136018
|
if (table.relations === undefined)
|
|
136020
136019
|
continue;
|
|
136021
136020
|
for (const drizzleRel of Object.values(table.relations)) {
|
|
136022
|
-
if (!drizzleOrm.is(drizzleRel,
|
|
136021
|
+
if (!drizzleOrm.is(drizzleRel, _relations.One))
|
|
136023
136022
|
continue;
|
|
136024
136023
|
const tableConfig = sqliteCore.getTableConfig(drizzleRel.sourceTable);
|
|
136025
136024
|
const tableDbName = tableConfig.name;
|
|
@@ -136062,10 +136061,7 @@ const getSqliteInfo = (sqliteSchema, sqliteTables) => {
|
|
|
136062
136061
|
};
|
|
136063
136062
|
for (const table of Object.values(sqliteTables)) {
|
|
136064
136063
|
tableConfig = sqliteCore.getTableConfig(table);
|
|
136065
|
-
dbToTsColumnNamesMap =
|
|
136066
|
-
for (const [tsCol, col] of Object.entries(tableConfig.columns[0].table)) {
|
|
136067
|
-
dbToTsColumnNamesMap[col.name] = tsCol;
|
|
136068
|
-
}
|
|
136064
|
+
dbToTsColumnNamesMap = getDbToTsColumnNamesMap(table);
|
|
136069
136065
|
const newRelations = tableConfig.foreignKeys.map((fk) => {
|
|
136070
136066
|
const table = dbToTsTableNamesMap[tableConfig.name];
|
|
136071
136067
|
const refTable = dbToTsTableNamesMap[drizzleOrm.getTableName(fk.reference().foreignTable)];
|
|
@@ -136116,7 +136112,7 @@ const getSqliteInfo = (sqliteSchema, sqliteTables) => {
|
|
|
136116
136112
|
name: dbToTsColumnNamesMap[column.name],
|
|
136117
136113
|
columnType: column.getSQLType(),
|
|
136118
136114
|
typeParams: getTypeParams(column.getSQLType()),
|
|
136119
|
-
dataType: column.dataType,
|
|
136115
|
+
dataType: column.dataType.split(' ')[0],
|
|
136120
136116
|
hasDefault: column.hasDefault,
|
|
136121
136117
|
default: column.default,
|
|
136122
136118
|
enumValues: column.enumValues,
|