drizzle-orm 0.30.1-97e97e1 → 0.30.1-bfc757f
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/libsql/migrator.cjs +2 -29
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.js +2 -29
- package/libsql/migrator.js.map +1 -1
- package/package.json +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/libsql/migrator.cjs
CHANGED
|
@@ -22,36 +22,9 @@ __export(migrator_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(migrator_exports);
|
|
24
24
|
var import_migrator = require("../migrator.cjs");
|
|
25
|
-
|
|
26
|
-
async function migrate(db, config) {
|
|
25
|
+
function migrate(db, config) {
|
|
27
26
|
const migrations = (0, import_migrator.readMigrationFiles)(config);
|
|
28
|
-
|
|
29
|
-
const migrationTableCreate = import_sql.sql`
|
|
30
|
-
CREATE TABLE IF NOT EXISTS ${import_sql.sql.identifier(migrationsTable)} (
|
|
31
|
-
id SERIAL PRIMARY KEY,
|
|
32
|
-
hash text NOT NULL,
|
|
33
|
-
created_at numeric
|
|
34
|
-
)
|
|
35
|
-
`;
|
|
36
|
-
await db.session.run(migrationTableCreate);
|
|
37
|
-
const dbMigrations = await db.values(
|
|
38
|
-
import_sql.sql`SELECT id, hash, created_at FROM ${import_sql.sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
|
|
39
|
-
);
|
|
40
|
-
const lastDbMigration = dbMigrations[0] ?? void 0;
|
|
41
|
-
const statementToBatch = [];
|
|
42
|
-
for (const migration of migrations) {
|
|
43
|
-
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
|
|
44
|
-
for (const stmt of migration.sql) {
|
|
45
|
-
statementToBatch.push(db.run(import_sql.sql.raw(stmt)));
|
|
46
|
-
}
|
|
47
|
-
statementToBatch.push(
|
|
48
|
-
db.run(
|
|
49
|
-
import_sql.sql`INSERT INTO ${import_sql.sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
|
|
50
|
-
)
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
await db.session.batch(statementToBatch);
|
|
27
|
+
return db.dialect.migrate(migrations, db.session, config);
|
|
55
28
|
}
|
|
56
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
30
|
0 && (module.exports = {
|
package/libsql/migrator.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/libsql/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/libsql/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { LibSQLDatabase } from './driver.ts';\n\nexport function migrate<TSchema extends Record<string, unknown>>(\n\tdb: LibSQLDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\treturn db.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC;AAG5B,SAAS,QACf,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAC5C,SAAO,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACzD;","names":[]}
|
package/libsql/migrator.js
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
1
|
import { readMigrationFiles } from "../migrator.js";
|
|
2
|
-
|
|
3
|
-
async function migrate(db, config) {
|
|
2
|
+
function migrate(db, config) {
|
|
4
3
|
const migrations = readMigrationFiles(config);
|
|
5
|
-
|
|
6
|
-
const migrationTableCreate = sql`
|
|
7
|
-
CREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsTable)} (
|
|
8
|
-
id SERIAL PRIMARY KEY,
|
|
9
|
-
hash text NOT NULL,
|
|
10
|
-
created_at numeric
|
|
11
|
-
)
|
|
12
|
-
`;
|
|
13
|
-
await db.session.run(migrationTableCreate);
|
|
14
|
-
const dbMigrations = await db.values(
|
|
15
|
-
sql`SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
|
|
16
|
-
);
|
|
17
|
-
const lastDbMigration = dbMigrations[0] ?? void 0;
|
|
18
|
-
const statementToBatch = [];
|
|
19
|
-
for (const migration of migrations) {
|
|
20
|
-
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
|
|
21
|
-
for (const stmt of migration.sql) {
|
|
22
|
-
statementToBatch.push(db.run(sql.raw(stmt)));
|
|
23
|
-
}
|
|
24
|
-
statementToBatch.push(
|
|
25
|
-
db.run(
|
|
26
|
-
sql`INSERT INTO ${sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
|
|
27
|
-
)
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
await db.session.batch(statementToBatch);
|
|
4
|
+
return db.dialect.migrate(migrations, db.session, config);
|
|
32
5
|
}
|
|
33
6
|
export {
|
|
34
7
|
migrate
|
package/libsql/migrator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/libsql/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/libsql/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { LibSQLDatabase } from './driver.ts';\n\nexport function migrate<TSchema extends Record<string, unknown>>(\n\tdb: LibSQLDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\treturn db.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":"AACA,SAAS,0BAA0B;AAG5B,SAAS,QACf,IACA,QACC;AACD,QAAM,aAAa,mBAAmB,MAAM;AAC5C,SAAO,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACzD;","names":[]}
|
package/package.json
CHANGED
package/version.cjs
CHANGED
package/version.d.cts
CHANGED
package/version.d.ts
CHANGED
package/version.js
CHANGED