drizzle-orm 1.0.0-beta.17-08eddf2 → 1.0.0-beta.17-875d549
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/aws-data-api/pg/migrator.d.cts +2 -2
- package/aws-data-api/pg/migrator.d.ts +2 -2
- package/better-sqlite3/migrator.d.cts +2 -2
- package/bun-sql/migrator.d.cts +5 -5
- package/bun-sql/migrator.d.ts +5 -5
- package/bun-sql/mysql/migrator.d.cts +2 -2
- package/bun-sql/mysql/migrator.d.ts +2 -2
- package/bun-sql/postgres/migrator.d.cts +2 -2
- package/bun-sql/postgres/migrator.d.ts +2 -2
- package/bun-sql/sqlite/migrator.d.cts +2 -2
- package/bun-sql/sqlite/migrator.d.ts +2 -2
- package/cockroach/migrator.d.cts +2 -2
- package/cockroach/migrator.d.ts +2 -2
- package/effect-postgres/migrator.d.cts +1 -1
- package/effect-postgres/migrator.d.ts +1 -1
- package/gel-core/utils.d.cts +3 -3
- package/mysql-core/utils.d.cts +2 -2
- package/mysql-core/utils.d.ts +2 -2
- package/mysql2/migrator.d.cts +2 -2
- package/mysql2/migrator.d.ts +2 -2
- package/neon/rls.d.cts +2 -2
- package/neon-serverless/migrator.d.cts +2 -2
- package/neon-serverless/migrator.d.ts +2 -2
- package/node-mssql/migrator.d.cts +2 -2
- package/node-mssql/migrator.d.ts +2 -2
- package/node-sqlite/migrator.d.cts +2 -2
- package/node-sqlite/migrator.d.ts +2 -2
- package/op-sqlite/migrator.d.cts +2 -2
- package/op-sqlite/migrator.d.ts +2 -2
- package/package.json +1 -8
- package/pg-core/effect/session.d.cts +1 -1
- package/pg-core/effect/session.d.ts +1 -1
- package/pglite/migrator.d.cts +2 -2
- package/pglite/migrator.d.ts +2 -2
- package/planetscale-serverless/migrator.d.cts +2 -2
- package/postgres-js/migrator.d.cts +2 -2
- package/singlestore/migrator.d.cts +2 -2
- package/singlestore/migrator.d.ts +2 -2
- package/sql-js/migrator.d.cts +2 -2
- package/sql-js/migrator.d.ts +2 -2
- package/sqlite-core/query-builders/raw.d.cts +2 -2
- package/sqlite-core/utils.d.ts +2 -2
- package/supabase/rls.d.cts +17 -17
- package/supabase/rls.d.ts +3 -3
- package/tidb-serverless/migrator.d.ts +2 -2
- package/tursodatabase/migrator.d.cts +2 -2
- package/tursodatabase/migrator.d.ts +2 -2
- package/up-migrations/pg.cjs +1 -1
- package/up-migrations/pg.cjs.map +1 -1
- package/up-migrations/pg.js +1 -1
- package/up-migrations/pg.js.map +1 -1
- package/vercel-postgres/migrator.d.cts +2 -2
- package/vercel-postgres/migrator.d.ts +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AwsDataApiPgDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts17 from "../../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/aws-data-api/pg/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: AwsDataApiPgDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: AwsDataApiPgDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts17.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AwsDataApiPgDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts19 from "../../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/aws-data-api/pg/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: AwsDataApiPgDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: AwsDataApiPgDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts19.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BetterSQLite3Database } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts22 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/better-sqlite3/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BetterSQLite3Database<TSchema, TRelations>, config: MigrationConfig): void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BetterSQLite3Database<TSchema, TRelations>, config: MigrationConfig): void | __migrator_ts22.MigratorInitFailResponse;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
package/bun-sql/migrator.d.cts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { BunMySqlDatabase } from "./mysql/driver.cjs";
|
|
2
2
|
import { BunSQLDatabase } from "./postgres/driver.cjs";
|
|
3
3
|
import { BunSQLiteDatabase } from "./sqlite/driver.cjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as __migrator_ts9 from "../migrator.cjs";
|
|
5
5
|
import { MigrationConfig } from "../migrator.cjs";
|
|
6
6
|
import { AnyRelations } from "../relations.cjs";
|
|
7
7
|
|
|
8
8
|
//#region src/bun-sql/migrator.d.ts
|
|
9
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
9
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts9.MigratorInitFailResponse>;
|
|
10
10
|
declare namespace migrate {
|
|
11
|
-
function postgres<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
12
|
-
function sqlite<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
13
|
-
function mysql<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunMySqlDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
11
|
+
function postgres<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts9.MigratorInitFailResponse>;
|
|
12
|
+
function sqlite<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts9.MigratorInitFailResponse>;
|
|
13
|
+
function mysql<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunMySqlDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts9.MigratorInitFailResponse>;
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
export { migrate };
|
package/bun-sql/migrator.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { BunMySqlDatabase } from "./mysql/driver.js";
|
|
2
2
|
import { BunSQLDatabase } from "./postgres/driver.js";
|
|
3
3
|
import { BunSQLiteDatabase } from "./sqlite/driver.js";
|
|
4
|
-
import * as
|
|
4
|
+
import * as __migrator_ts12 from "../migrator.js";
|
|
5
5
|
import { MigrationConfig } from "../migrator.js";
|
|
6
6
|
import { AnyRelations } from "../relations.js";
|
|
7
7
|
|
|
8
8
|
//#region src/bun-sql/migrator.d.ts
|
|
9
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
9
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts12.MigratorInitFailResponse>;
|
|
10
10
|
declare namespace migrate {
|
|
11
|
-
function postgres<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
12
|
-
function sqlite<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
13
|
-
function mysql<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunMySqlDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
11
|
+
function postgres<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts12.MigratorInitFailResponse>;
|
|
12
|
+
function sqlite<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts12.MigratorInitFailResponse>;
|
|
13
|
+
function mysql<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunMySqlDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts12.MigratorInitFailResponse>;
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
export { migrate };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BunMySqlDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts13 from "../../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/bun-sql/mysql/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunMySqlDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunMySqlDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts13.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BunMySqlDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts17 from "../../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/bun-sql/mysql/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunMySqlDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunMySqlDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts17.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BunSQLDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts14 from "../../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/bun-sql/postgres/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts14.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BunSQLDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts11 from "../../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/bun-sql/postgres/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts11.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BunSQLiteDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts15 from "../../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/bun-sql/sqlite/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts15.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BunSQLiteDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts16 from "../../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/bun-sql/sqlite/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: BunSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts16.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
package/cockroach/migrator.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NodeCockroachDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts20 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/cockroach/migrator.d.ts
|
|
6
|
-
declare function migrate<TSchema extends Record<string, unknown>>(db: NodeCockroachDatabase<TSchema>, config: MigrationConfig): Promise<void |
|
|
6
|
+
declare function migrate<TSchema extends Record<string, unknown>>(db: NodeCockroachDatabase<TSchema>, config: MigrationConfig): Promise<void | __migrator_ts20.MigratorInitFailResponse>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { migrate };
|
|
9
9
|
//# sourceMappingURL=migrator.d.cts.map
|
package/cockroach/migrator.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NodeCockroachDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts9 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
|
|
5
5
|
//#region src/cockroach/migrator.d.ts
|
|
6
|
-
declare function migrate<TSchema extends Record<string, unknown>>(db: NodeCockroachDatabase<TSchema>, config: MigrationConfig): Promise<void |
|
|
6
|
+
declare function migrate<TSchema extends Record<string, unknown>>(db: NodeCockroachDatabase<TSchema>, config: MigrationConfig): Promise<void | __migrator_ts9.MigratorInitFailResponse>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { migrate };
|
|
9
9
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -6,7 +6,7 @@ import * as effect_Effect0 from "effect/Effect";
|
|
|
6
6
|
import * as _effect_sql_SqlError0 from "@effect/sql/SqlError";
|
|
7
7
|
|
|
8
8
|
//#region src/effect-postgres/migrator.d.ts
|
|
9
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: EffectPgDatabase<TSchema, TRelations>, config: MigrationConfig): effect_Effect0.Effect<undefined, EffectDrizzleQueryError | _effect_sql_SqlError0.SqlError
|
|
9
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: EffectPgDatabase<TSchema, TRelations>, config: MigrationConfig): effect_Effect0.Effect<undefined, EffectDrizzleQueryError | MigratorInitError | _effect_sql_SqlError0.SqlError, never>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { migrate };
|
|
12
12
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -6,7 +6,7 @@ import * as effect_Effect0 from "effect/Effect";
|
|
|
6
6
|
import * as _effect_sql_SqlError0 from "@effect/sql/SqlError";
|
|
7
7
|
|
|
8
8
|
//#region src/effect-postgres/migrator.d.ts
|
|
9
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: EffectPgDatabase<TSchema, TRelations>, config: MigrationConfig): effect_Effect0.Effect<undefined, EffectDrizzleQueryError | _effect_sql_SqlError0.SqlError
|
|
9
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: EffectPgDatabase<TSchema, TRelations>, config: MigrationConfig): effect_Effect0.Effect<undefined, EffectDrizzleQueryError | MigratorInitError | _effect_sql_SqlError0.SqlError, never>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { migrate };
|
|
12
12
|
//# sourceMappingURL=migrator.d.ts.map
|
package/gel-core/utils.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ import "./columns/index.cjs";
|
|
|
10
10
|
import { GelViewBase } from "./view-base.cjs";
|
|
11
11
|
import { GelMaterializedView, GelMaterializedViewWithConfig, GelView, ViewWithConfig } from "./view.cjs";
|
|
12
12
|
import "./index.cjs";
|
|
13
|
-
import * as
|
|
13
|
+
import * as __sql_sql_ts1 from "../sql/sql.cjs";
|
|
14
14
|
import { SQL } from "../sql/sql.cjs";
|
|
15
15
|
import { Subquery } from "../subquery.cjs";
|
|
16
16
|
|
|
@@ -33,7 +33,7 @@ declare function getViewConfig<TName extends string = string, TExisting extends
|
|
|
33
33
|
name: TName;
|
|
34
34
|
originalName: TName;
|
|
35
35
|
schema: string | undefined;
|
|
36
|
-
selectedFields:
|
|
36
|
+
selectedFields: __sql_sql_ts1.ColumnsSelection;
|
|
37
37
|
isExisting: TExisting;
|
|
38
38
|
query: TExisting extends true ? undefined : SQL<unknown>;
|
|
39
39
|
isAlias: boolean;
|
|
@@ -46,7 +46,7 @@ declare function getMaterializedViewConfig<TName extends string = string, TExist
|
|
|
46
46
|
name: TName;
|
|
47
47
|
originalName: TName;
|
|
48
48
|
schema: string | undefined;
|
|
49
|
-
selectedFields:
|
|
49
|
+
selectedFields: __sql_sql_ts1.ColumnsSelection;
|
|
50
50
|
isExisting: TExisting;
|
|
51
51
|
query: TExisting extends true ? undefined : SQL<unknown>;
|
|
52
52
|
isAlias: boolean;
|
package/mysql-core/utils.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ import { MySqlViewBase } from "./view-base.cjs";
|
|
|
9
9
|
import { IndexForHint } from "./query-builders/select.cjs";
|
|
10
10
|
import { MySqlView } from "./view.cjs";
|
|
11
11
|
import "./index.cjs";
|
|
12
|
-
import * as
|
|
12
|
+
import * as __sql_sql_ts5 from "../sql/sql.cjs";
|
|
13
13
|
import { SQL } from "../sql/sql.cjs";
|
|
14
14
|
import { Subquery } from "../subquery.cjs";
|
|
15
15
|
|
|
@@ -33,7 +33,7 @@ declare function getViewConfig<TName extends string = string, TExisting extends
|
|
|
33
33
|
name: TName;
|
|
34
34
|
originalName: TName;
|
|
35
35
|
schema: string | undefined;
|
|
36
|
-
selectedFields:
|
|
36
|
+
selectedFields: __sql_sql_ts5.ColumnsSelection;
|
|
37
37
|
isExisting: TExisting;
|
|
38
38
|
query: TExisting extends true ? undefined : SQL<unknown>;
|
|
39
39
|
isAlias: boolean;
|
package/mysql-core/utils.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { IndexForHint } from "./query-builders/select.js";
|
|
|
10
10
|
import { MySqlView } from "./view.js";
|
|
11
11
|
import "./index.js";
|
|
12
12
|
import { Subquery } from "../subquery.js";
|
|
13
|
-
import * as
|
|
13
|
+
import * as __sql_sql_ts2 from "../sql/sql.js";
|
|
14
14
|
import { SQL } from "../sql/sql.js";
|
|
15
15
|
|
|
16
16
|
//#region src/mysql-core/utils.d.ts
|
|
@@ -33,7 +33,7 @@ declare function getViewConfig<TName extends string = string, TExisting extends
|
|
|
33
33
|
name: TName;
|
|
34
34
|
originalName: TName;
|
|
35
35
|
schema: string | undefined;
|
|
36
|
-
selectedFields:
|
|
36
|
+
selectedFields: __sql_sql_ts2.ColumnsSelection;
|
|
37
37
|
isExisting: TExisting;
|
|
38
38
|
query: TExisting extends true ? undefined : SQL<unknown>;
|
|
39
39
|
isAlias: boolean;
|
package/mysql2/migrator.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MySql2Database } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts21 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/mysql2/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: MySql2Database<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: MySql2Database<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts21.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
package/mysql2/migrator.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MySql2Database } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts4 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/mysql2/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: MySql2Database<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: MySql2Database<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts4.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
package/neon/rls.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SQL } from "../sql/sql.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __pg_core_index_ts46 from "../pg-core/index.cjs";
|
|
3
3
|
import { AnyPgColumn, PgPolicyToOption } from "../pg-core/index.cjs";
|
|
4
4
|
import { PgRole } from "../pg-core/roles.cjs";
|
|
5
5
|
|
|
@@ -18,7 +18,7 @@ declare const crudPolicy: (options: {
|
|
|
18
18
|
role: PgPolicyToOption;
|
|
19
19
|
read: SQL | boolean | null;
|
|
20
20
|
modify: SQL | boolean | null;
|
|
21
|
-
}) => (
|
|
21
|
+
}) => (__pg_core_index_ts46.PgPolicy | undefined)[];
|
|
22
22
|
declare const authenticatedRole: PgRole;
|
|
23
23
|
declare const anonymousRole: PgRole;
|
|
24
24
|
declare const authUid: (userIdColumn: AnyPgColumn) => SQL<unknown>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NeonDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts16 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/neon-serverless/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: NeonDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: NeonDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts16.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NeonDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts18 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/neon-serverless/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: NeonDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: NeonDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts18.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NodeMsSqlDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts18 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/node-mssql/migrator.d.ts
|
|
6
|
-
declare function migrate<TSchema extends Record<string, unknown>>(db: NodeMsSqlDatabase<TSchema>, config: MigrationConfig): Promise<void |
|
|
6
|
+
declare function migrate<TSchema extends Record<string, unknown>>(db: NodeMsSqlDatabase<TSchema>, config: MigrationConfig): Promise<void | __migrator_ts18.MigratorInitFailResponse>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { migrate };
|
|
9
9
|
//# sourceMappingURL=migrator.d.cts.map
|
package/node-mssql/migrator.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NodeMsSqlDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts20 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
|
|
5
5
|
//#region src/node-mssql/migrator.d.ts
|
|
6
|
-
declare function migrate<TSchema extends Record<string, unknown>>(db: NodeMsSqlDatabase<TSchema>, config: MigrationConfig): Promise<void |
|
|
6
|
+
declare function migrate<TSchema extends Record<string, unknown>>(db: NodeMsSqlDatabase<TSchema>, config: MigrationConfig): Promise<void | __migrator_ts20.MigratorInitFailResponse>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { migrate };
|
|
9
9
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NodeSQLiteDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts6 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations, EmptyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/node-sqlite/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(db: NodeSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(db: NodeSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): void | __migrator_ts6.MigratorInitFailResponse;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NodeSQLiteDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts22 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations, EmptyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/node-sqlite/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(db: NodeSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(db: NodeSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig): void | __migrator_ts22.MigratorInitFailResponse;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
package/op-sqlite/migrator.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OPSQLiteDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts4 from "../migrator.cjs";
|
|
3
3
|
import { AnyRelations } from "../relations.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/op-sqlite/migrator.d.ts
|
|
6
6
|
interface MigrationConfig$1 {
|
|
7
7
|
migrations: Record<string, string>;
|
|
8
8
|
}
|
|
9
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: OPSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig$1): Promise<void |
|
|
9
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: OPSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig$1): Promise<void | __migrator_ts4.MigratorInitFailResponse>;
|
|
10
10
|
interface State {
|
|
11
11
|
success: boolean;
|
|
12
12
|
error?: Error;
|
package/op-sqlite/migrator.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OPSQLiteDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts3 from "../migrator.js";
|
|
3
3
|
import { AnyRelations } from "../relations.js";
|
|
4
4
|
|
|
5
5
|
//#region src/op-sqlite/migrator.d.ts
|
|
6
6
|
interface MigrationConfig$1 {
|
|
7
7
|
migrations: Record<string, string>;
|
|
8
8
|
}
|
|
9
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: OPSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig$1): Promise<void |
|
|
9
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: OPSQLiteDatabase<TSchema, TRelations>, config: MigrationConfig$1): Promise<void | __migrator_ts3.MigratorInitFailResponse>;
|
|
10
10
|
interface State {
|
|
11
11
|
success: boolean;
|
|
12
12
|
error?: Error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-orm",
|
|
3
|
-
"version": "1.0.0-beta.17-
|
|
3
|
+
"version": "1.0.0-beta.17-875d549",
|
|
4
4
|
"description": "Drizzle ORM package for SQL databases",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"@op-engineering/op-sqlite": ">=2",
|
|
59
59
|
"@opentelemetry/api": "^1.4.1",
|
|
60
60
|
"@planetscale/database": ">=1.13",
|
|
61
|
-
"@prisma/client": "*",
|
|
62
61
|
"@sinclair/typebox": ">=0.34.8",
|
|
63
62
|
"@sqlitecloud/drivers": ">=1.0.653",
|
|
64
63
|
"@tidbcloud/serverless": "*",
|
|
@@ -166,12 +165,6 @@
|
|
|
166
165
|
"@tidbcloud/serverless": {
|
|
167
166
|
"optional": true
|
|
168
167
|
},
|
|
169
|
-
"prisma": {
|
|
170
|
-
"optional": true
|
|
171
|
-
},
|
|
172
|
-
"@prisma/client": {
|
|
173
|
-
"optional": true
|
|
174
|
-
},
|
|
175
168
|
"@sinclair/typebox": {
|
|
176
169
|
"optional": true
|
|
177
170
|
},
|
|
@@ -56,7 +56,7 @@ declare abstract class PgEffectTransaction<TEffectHKT extends QueryEffectHKTBase
|
|
|
56
56
|
rollback(): EffectTransactionRollbackError;
|
|
57
57
|
setTransaction(config: PgTransactionConfig): QueryEffectKind<TEffectHKT, void>;
|
|
58
58
|
}
|
|
59
|
-
declare const migrate: <TEffectHKT extends QueryEffectHKTBase>(migrations: MigrationMeta[], session: PgEffectSession<TEffectHKT, PgQueryResultHKT, Record<string, never>, EmptyRelations, V1.ExtractTablesWithRelations<Record<string, never>>>, config: string | MigrationConfig) => Effect.Effect<undefined,
|
|
59
|
+
declare const migrate: <TEffectHKT extends QueryEffectHKTBase>(migrations: MigrationMeta[], session: PgEffectSession<TEffectHKT, PgQueryResultHKT, Record<string, never>, EmptyRelations, V1.ExtractTablesWithRelations<Record<string, never>>>, config: string | MigrationConfig) => Effect.Effect<undefined, MigratorInitError | TEffectHKT["error"] | SqlError, TEffectHKT["context"]>;
|
|
60
60
|
//#endregion
|
|
61
61
|
export { PgEffectPreparedQuery, PgEffectSession, PgEffectTransaction, migrate };
|
|
62
62
|
//# sourceMappingURL=session.d.cts.map
|
|
@@ -56,7 +56,7 @@ declare abstract class PgEffectTransaction<TEffectHKT extends QueryEffectHKTBase
|
|
|
56
56
|
rollback(): EffectTransactionRollbackError;
|
|
57
57
|
setTransaction(config: PgTransactionConfig): QueryEffectKind<TEffectHKT, void>;
|
|
58
58
|
}
|
|
59
|
-
declare const migrate: <TEffectHKT extends QueryEffectHKTBase>(migrations: MigrationMeta[], session: PgEffectSession<TEffectHKT, PgQueryResultHKT, Record<string, never>, EmptyRelations, V1.ExtractTablesWithRelations<Record<string, never>>>, config: string | MigrationConfig) => Effect.Effect<undefined,
|
|
59
|
+
declare const migrate: <TEffectHKT extends QueryEffectHKTBase>(migrations: MigrationMeta[], session: PgEffectSession<TEffectHKT, PgQueryResultHKT, Record<string, never>, EmptyRelations, V1.ExtractTablesWithRelations<Record<string, never>>>, config: string | MigrationConfig) => Effect.Effect<undefined, MigratorInitError | TEffectHKT["error"] | SqlError, TEffectHKT["context"]>;
|
|
60
60
|
//#endregion
|
|
61
61
|
export { PgEffectPreparedQuery, PgEffectSession, PgEffectTransaction, migrate };
|
|
62
62
|
//# sourceMappingURL=session.d.ts.map
|
package/pglite/migrator.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PgliteDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts1 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/pglite/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PgliteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PgliteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts1.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
package/pglite/migrator.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PgliteDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts2 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/pglite/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PgliteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PgliteDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts2.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PlanetScaleDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts2 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/planetscale-serverless/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PlanetScaleDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PlanetScaleDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts2.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PostgresJsDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts3 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/postgres-js/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PostgresJsDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PostgresJsDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts3.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SingleStoreDriverDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts19 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/singlestore/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: SingleStoreDriverDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: SingleStoreDriverDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts19.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SingleStoreDriverDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts21 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/singlestore/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: SingleStoreDriverDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: SingleStoreDriverDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts21.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
package/sql-js/migrator.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SQLJsDatabase } from "./driver.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts8 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations, EmptyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/sql-js/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(db: SQLJsDatabase<TSchema, TRelations>, config: MigrationConfig): void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(db: SQLJsDatabase<TSchema, TRelations>, config: MigrationConfig): void | __migrator_ts8.MigratorInitFailResponse;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
package/sql-js/migrator.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SQLJsDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts8 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations, EmptyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/sql-js/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(db: SQLJsDatabase<TSchema, TRelations>, config: MigrationConfig): void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(db: SQLJsDatabase<TSchema, TRelations>, config: MigrationConfig): void | __migrator_ts8.MigratorInitFailResponse;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SQLiteAsyncDialect } from "../dialect.cjs";
|
|
2
2
|
import { entityKind } from "../../entity.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as __sql_sql_ts7 from "../../sql/sql.cjs";
|
|
4
4
|
import { SQL, SQLWrapper } from "../../sql/sql.cjs";
|
|
5
5
|
import { PreparedQuery } from "../../session.cjs";
|
|
6
6
|
import { QueryPromise } from "../../query-promise.cjs";
|
|
@@ -25,7 +25,7 @@ declare class SQLiteRaw<TResult> extends QueryPromise<TResult> implements Runnab
|
|
|
25
25
|
getSQL: () => SQL, action: SQLiteRawAction, dialect: SQLiteAsyncDialect, mapBatchResult: (result: unknown) => unknown);
|
|
26
26
|
getQuery(): {
|
|
27
27
|
method: SQLiteRawAction;
|
|
28
|
-
typings?:
|
|
28
|
+
typings?: __sql_sql_ts7.QueryTypingsValue[];
|
|
29
29
|
sql: string;
|
|
30
30
|
params: unknown[];
|
|
31
31
|
};
|
package/sqlite-core/utils.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { UniqueConstraint } from "./unique-constraint.js";
|
|
|
9
9
|
import { SQLiteTable } from "./table.js";
|
|
10
10
|
import "./index.js";
|
|
11
11
|
import { Subquery } from "../subquery.js";
|
|
12
|
-
import * as
|
|
12
|
+
import * as __sql_sql_ts1 from "../sql/sql.js";
|
|
13
13
|
import { SQL } from "../sql/sql.js";
|
|
14
14
|
|
|
15
15
|
//#region src/sqlite-core/utils.d.ts
|
|
@@ -28,7 +28,7 @@ declare function getViewConfig<TName extends string = string, TExisting extends
|
|
|
28
28
|
name: TName;
|
|
29
29
|
originalName: TName;
|
|
30
30
|
schema: string | undefined;
|
|
31
|
-
selectedFields:
|
|
31
|
+
selectedFields: __sql_sql_ts1.ColumnsSelection;
|
|
32
32
|
isExisting: TExisting;
|
|
33
33
|
query: TExisting extends true ? undefined : SQL<unknown>;
|
|
34
34
|
isAlias: boolean;
|
package/supabase/rls.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as __sql_sql_ts3 from "../sql/sql.cjs";
|
|
2
|
+
import * as __pg_core_index_ts17 from "../pg-core/index.cjs";
|
|
3
3
|
import * as __pg_core_roles_ts0 from "../pg-core/roles.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/supabase/rls.d.ts
|
|
@@ -8,11 +8,11 @@ declare const authenticatedRole: __pg_core_roles_ts0.PgRole;
|
|
|
8
8
|
declare const serviceRole: __pg_core_roles_ts0.PgRole;
|
|
9
9
|
declare const postgresRole: __pg_core_roles_ts0.PgRole;
|
|
10
10
|
declare const supabaseAuthAdminRole: __pg_core_roles_ts0.PgRole;
|
|
11
|
-
declare const authUsers:
|
|
11
|
+
declare const authUsers: __pg_core_index_ts17.PgTableWithColumns<{
|
|
12
12
|
name: "users";
|
|
13
13
|
schema: "auth";
|
|
14
14
|
columns: {
|
|
15
|
-
id:
|
|
15
|
+
id: __pg_core_index_ts17.PgBuildColumn<"users", __pg_core_index_ts17.SetNotNull<__pg_core_index_ts17.SetIsPrimaryKey<__pg_core_index_ts17.PgUUIDBuilder>>, {
|
|
16
16
|
name: string;
|
|
17
17
|
tableName: "users";
|
|
18
18
|
dataType: "string uuid";
|
|
@@ -27,7 +27,7 @@ declare const authUsers: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
27
27
|
identity: undefined;
|
|
28
28
|
generated: undefined;
|
|
29
29
|
}>;
|
|
30
|
-
email:
|
|
30
|
+
email: __pg_core_index_ts17.PgBuildColumn<"users", __pg_core_index_ts17.PgVarcharBuilder<[string, ...string[]]>, {
|
|
31
31
|
name: string;
|
|
32
32
|
tableName: "users";
|
|
33
33
|
dataType: "string";
|
|
@@ -42,7 +42,7 @@ declare const authUsers: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
42
42
|
identity: undefined;
|
|
43
43
|
generated: undefined;
|
|
44
44
|
}>;
|
|
45
|
-
phone:
|
|
45
|
+
phone: __pg_core_index_ts17.PgBuildColumn<"users", __pg_core_index_ts17.PgTextBuilder<[string, ...string[]]>, {
|
|
46
46
|
name: string;
|
|
47
47
|
tableName: "users";
|
|
48
48
|
dataType: "string";
|
|
@@ -57,7 +57,7 @@ declare const authUsers: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
57
57
|
identity: undefined;
|
|
58
58
|
generated: undefined;
|
|
59
59
|
}>;
|
|
60
|
-
emailConfirmedAt:
|
|
60
|
+
emailConfirmedAt: __pg_core_index_ts17.PgBuildColumn<"users", __pg_core_index_ts17.PgTimestampBuilder, {
|
|
61
61
|
name: string;
|
|
62
62
|
tableName: "users";
|
|
63
63
|
dataType: "object date";
|
|
@@ -72,7 +72,7 @@ declare const authUsers: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
72
72
|
identity: undefined;
|
|
73
73
|
generated: undefined;
|
|
74
74
|
}>;
|
|
75
|
-
phoneConfirmedAt:
|
|
75
|
+
phoneConfirmedAt: __pg_core_index_ts17.PgBuildColumn<"users", __pg_core_index_ts17.PgTimestampBuilder, {
|
|
76
76
|
name: string;
|
|
77
77
|
tableName: "users";
|
|
78
78
|
dataType: "object date";
|
|
@@ -87,7 +87,7 @@ declare const authUsers: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
87
87
|
identity: undefined;
|
|
88
88
|
generated: undefined;
|
|
89
89
|
}>;
|
|
90
|
-
lastSignInAt:
|
|
90
|
+
lastSignInAt: __pg_core_index_ts17.PgBuildColumn<"users", __pg_core_index_ts17.PgTimestampBuilder, {
|
|
91
91
|
name: string;
|
|
92
92
|
tableName: "users";
|
|
93
93
|
dataType: "object date";
|
|
@@ -102,7 +102,7 @@ declare const authUsers: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
102
102
|
identity: undefined;
|
|
103
103
|
generated: undefined;
|
|
104
104
|
}>;
|
|
105
|
-
createdAt:
|
|
105
|
+
createdAt: __pg_core_index_ts17.PgBuildColumn<"users", __pg_core_index_ts17.PgTimestampBuilder, {
|
|
106
106
|
name: string;
|
|
107
107
|
tableName: "users";
|
|
108
108
|
dataType: "object date";
|
|
@@ -117,7 +117,7 @@ declare const authUsers: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
117
117
|
identity: undefined;
|
|
118
118
|
generated: undefined;
|
|
119
119
|
}>;
|
|
120
|
-
updatedAt:
|
|
120
|
+
updatedAt: __pg_core_index_ts17.PgBuildColumn<"users", __pg_core_index_ts17.PgTimestampBuilder, {
|
|
121
121
|
name: string;
|
|
122
122
|
tableName: "users";
|
|
123
123
|
dataType: "object date";
|
|
@@ -135,11 +135,11 @@ declare const authUsers: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
135
135
|
};
|
|
136
136
|
dialect: "pg";
|
|
137
137
|
}>;
|
|
138
|
-
declare const realtimeMessages:
|
|
138
|
+
declare const realtimeMessages: __pg_core_index_ts17.PgTableWithColumns<{
|
|
139
139
|
name: "messages";
|
|
140
140
|
schema: "realtime";
|
|
141
141
|
columns: {
|
|
142
|
-
id:
|
|
142
|
+
id: __pg_core_index_ts17.PgBuildColumn<"messages", __pg_core_index_ts17.SetIsPrimaryKey<__pg_core_index_ts17.PgBigSerial64Builder>, {
|
|
143
143
|
name: string;
|
|
144
144
|
tableName: "messages";
|
|
145
145
|
dataType: "bigint int64";
|
|
@@ -154,7 +154,7 @@ declare const realtimeMessages: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
154
154
|
identity: undefined;
|
|
155
155
|
generated: undefined;
|
|
156
156
|
}>;
|
|
157
|
-
topic:
|
|
157
|
+
topic: __pg_core_index_ts17.PgBuildColumn<"messages", __pg_core_index_ts17.SetNotNull<__pg_core_index_ts17.PgTextBuilder<[string, ...string[]]>>, {
|
|
158
158
|
name: string;
|
|
159
159
|
tableName: "messages";
|
|
160
160
|
dataType: "string";
|
|
@@ -169,7 +169,7 @@ declare const realtimeMessages: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
169
169
|
identity: undefined;
|
|
170
170
|
generated: undefined;
|
|
171
171
|
}>;
|
|
172
|
-
extension:
|
|
172
|
+
extension: __pg_core_index_ts17.PgBuildColumn<"messages", __pg_core_index_ts17.SetNotNull<__pg_core_index_ts17.PgTextBuilder<["presence", "broadcast", "postgres_changes"]>>, {
|
|
173
173
|
name: string;
|
|
174
174
|
tableName: "messages";
|
|
175
175
|
dataType: "string enum";
|
|
@@ -187,8 +187,8 @@ declare const realtimeMessages: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
187
187
|
};
|
|
188
188
|
dialect: "pg";
|
|
189
189
|
}>;
|
|
190
|
-
declare const authUid:
|
|
191
|
-
declare const realtimeTopic:
|
|
190
|
+
declare const authUid: __sql_sql_ts3.SQL<unknown>;
|
|
191
|
+
declare const realtimeTopic: __sql_sql_ts3.SQL<unknown>;
|
|
192
192
|
//#endregion
|
|
193
193
|
export { anonRole, authUid, authUsers, authenticatedRole, postgresRole, realtimeMessages, realtimeTopic, serviceRole, supabaseAuthAdminRole };
|
|
194
194
|
//# sourceMappingURL=rls.d.cts.map
|
package/supabase/rls.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as __sql_sql_ts5 from "../sql/sql.js";
|
|
2
2
|
import * as __pg_core_index_ts18 from "../pg-core/index.js";
|
|
3
3
|
import * as __pg_core_roles_ts0 from "../pg-core/roles.js";
|
|
4
4
|
|
|
@@ -187,8 +187,8 @@ declare const realtimeMessages: __pg_core_index_ts18.PgTableWithColumns<{
|
|
|
187
187
|
};
|
|
188
188
|
dialect: "pg";
|
|
189
189
|
}>;
|
|
190
|
-
declare const authUid:
|
|
191
|
-
declare const realtimeTopic:
|
|
190
|
+
declare const authUid: __sql_sql_ts5.SQL<unknown>;
|
|
191
|
+
declare const realtimeTopic: __sql_sql_ts5.SQL<unknown>;
|
|
192
192
|
//#endregion
|
|
193
193
|
export { anonRole, authUid, authUsers, authenticatedRole, postgresRole, realtimeMessages, realtimeTopic, serviceRole, supabaseAuthAdminRole };
|
|
194
194
|
//# sourceMappingURL=rls.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TiDBServerlessDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts0 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/tidb-serverless/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: TiDBServerlessDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: TiDBServerlessDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts0.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TursoDatabaseDatabase } from "./driver-core.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts7 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/tursodatabase/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: TursoDatabaseDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: TursoDatabaseDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts7.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TursoDatabaseDatabase } from "./driver-core.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts1 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/tursodatabase/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: TursoDatabaseDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: TursoDatabaseDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts1.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|
package/up-migrations/pg.cjs
CHANGED
|
@@ -45,7 +45,7 @@ const upgradeFunctions = { 0: async (migrationsSchema, migrationsTable, session,
|
|
|
45
45
|
else unmatchedIds.push(dbRow.id);
|
|
46
46
|
}
|
|
47
47
|
if (unmatchedIds.length > 0) {
|
|
48
|
-
console.log(`Error:
|
|
48
|
+
console.log(`Error: While upgrading your database migrations table we found ${unmatchedIds.length} migrations (ids: ${unmatchedIds.join(", ")}) in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`);
|
|
49
49
|
process.exit(1);
|
|
50
50
|
}
|
|
51
51
|
try {
|
package/up-migrations/pg.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg.cjs","names":["result: { rows: T } | T","sql","upgradeFunctions: Record<\n\tnumber,\n\t(\n\t\tmigrationsSchema: string,\n\t\tmigrationsTable: string,\n\t\tsession:\n\t\t\t| PgAsyncSession\n\t\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\t\tlocalMigrations: MigrationMeta[],\n\t) => Promise<void>\n>","toApply: { id: number; name: string }[]","unmatchedIds: number[]","matched: MigrationMeta | undefined","err: any"],"sources":["../../src/up-migrations/pg.ts"],"sourcesContent":["import type { TablesRelationalConfig } from '~/_relations.ts';\nimport type { MigrationMeta } from '~/migrator.ts';\nimport type { NeonHttpSession } from '~/neon-http/session.ts';\nimport type { PgAsyncSession } from '~/pg-core/async/session.ts';\nimport type { AnyRelations } from '~/relations.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\nimport type { XataHttpSession } from '~/xata-http/session.ts';\n\nconst CURRENT_MIGRATION_TABLE_VERSION = 1;\n\ninterface UpgradeResult {\n\tnewDb?: boolean;\n\tprevVersion?: number;\n\tcurrentVersion?: number;\n}\n\nfunction getVersion(columns: string[]) {\n\tif (columns.includes('name')) return 1;\n\treturn 0;\n}\n\n// postgres.js returns array of objects\n// pg-proxy returns arrays of objects\n// node-postgres returns { rows: array of objects }\nasync function execute<T extends any[]>(\n\tsession:\n\t\t| PgAsyncSession\n\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\tsql: SQL,\n): Promise<T> {\n\tconst result: { rows: T } | T = await session.execute(sql);\n\tif ('rows' in result) return result.rows;\n\treturn result;\n}\n\n/**\n * Map of upgrade functions. Each key is the version being upgraded FROM,\n * and the function upgrades the table to the next version.\n */\nconst upgradeFunctions: Record<\n\tnumber,\n\t(\n\t\tmigrationsSchema: string,\n\t\tmigrationsTable: string,\n\t\tsession:\n\t\t\t| PgAsyncSession\n\t\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\t\tlocalMigrations: MigrationMeta[],\n\t) => Promise<void>\n> = {\n\t/**\n\t * Upgrade from version 0 to version 1:\n\t * 1. Read all existing DB migrations\n\t * 2. Sort localMigrations ASC by millis and if the same - sort by name\n\t * 3. Match each DB row to a local migration and backfill name\n\t * If multiple migrations share the same second, use hash matching as a tiebreaker\n\t * Not implemented for now -> If hash matching fails, fall back to serial id ordering\n\t * 5. Create extra column and backfill names for matched migrations\n\t */\n\t0: async (migrationsSchema, migrationsTable, session, localMigrations) => {\n\t\tconst table = sql`${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)}`;\n\n\t\t// 1. Read all existing DB migrations\n\t\t// Sort them by ids asc (order how they were applied)\n\t\tconst dbRows = await execute<{ id: number; hash: string; created_at: string }[]>(\n\t\t\tsession,\n\t\t\tsql`SELECT id, hash, created_at FROM ${table} ORDER BY id ASC`,\n\t\t);\n\n\t\tif (dbRows.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// 2. Sort ASC by millis and if the same - sort by name\n\t\tlocalMigrations.sort((a, b) =>\n\t\t\ta.folderMillis !== b.folderMillis ? a.folderMillis - b.folderMillis : (a.name ?? '').localeCompare(b.name ?? '')\n\t\t);\n\n\t\tconst byMillis = new Map<number, MigrationMeta[]>();\n\t\tconst byHash = new Map<string, MigrationMeta>();\n\t\tfor (const lm of localMigrations) {\n\t\t\tif (!byMillis.has(lm.folderMillis)) {\n\t\t\t\tbyMillis.set(lm.folderMillis, []);\n\t\t\t}\n\t\t\tbyMillis.get(lm.folderMillis)!.push(lm);\n\t\t\tbyHash.set(lm.hash, lm);\n\t\t}\n\n\t\t// \t3. Match each DB row to a local migration and backfill name\n\t\t// \tPriority: millis -> hash\n\t\tconst toApply: { id: number; name: string }[] = [];\n\t\tlet unmatchedIds: number[] = [];\n\n\t\tfor (const dbRow of dbRows) {\n\t\t\tconst stringified = String(dbRow.created_at);\n\t\t\tconst millis = Number(stringified.substring(0, stringified.length - 3) + '000');\n\t\t\tconst candidates = byMillis.get(millis);\n\n\t\t\tlet matched: MigrationMeta | undefined;\n\n\t\t\tif (candidates && candidates.length === 1) {\n\t\t\t\tmatched = candidates[0];\n\t\t\t} else if (candidates && candidates.length > 1) {\n\t\t\t\tmatched = candidates.find((c) => c.hash === dbRow.hash);\n\t\t\t} else {\n\t\t\t\tmatched = byHash.get(dbRow.hash);\n\t\t\t}\n\n\t\t\tif (matched) toApply.push({ id: dbRow.id, name: matched.name });\n\t\t\telse unmatchedIds.push(dbRow.id);\n\t\t}\n\n\t\t// 4. Check for unmatched\n\t\t// Out assumption on this migration flow is that all DB entries should be matched to a local migration\n\t\t// (if same seconds - fallback to hash, if hash fails - corner case)\n\t\t// If there are unmatched entries, it means that the local environment is missing migrations that have been applied to the DB,\n\t\t// which can lead to inconsistencies and potential issues when running future migrations\n\t\tif (unmatchedIds.length > 0) {\n\t\t\tconsole.log(\n\t\t\t\t`Error: Found ${unmatchedIds.length} migrations (ids: ${\n\t\t\t\t\tunmatchedIds.join(', ')\n\t\t\t\t}) in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\t// 5. Create extra column and backfill names for matched migrations\n\t\ttry {\n\t\t\tawait execute(session, sql`BEGIN`);\n\t\t\tawait execute(session, sql`ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS \"name\" text`);\n\t\t\tawait execute(\n\t\t\t\tsession,\n\t\t\t\tsql`ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS \"applied_at\" timestamp with time zone DEFAULT now()`,\n\t\t\t);\n\n\t\t\tfor (const backfillEntry of toApply) {\n\t\t\t\tawait execute(\n\t\t\t\t\tsession,\n\t\t\t\t\tsql`UPDATE ${table} SET name = ${backfillEntry.name}, applied_at = NULL WHERE id = ${backfillEntry.id}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait execute(session, sql`COMMIT`);\n\t\t} catch (err: any) {\n\t\t\tawait execute(session, sql`ROLLBACK`);\n\t\t\tthrow err;\n\t\t}\n\t},\n};\n\n/**\n * Detects the current version of the migrations table schema and upgrades it if needed.\n *\n * Version 0: Original schema (id, hash, created_at)\n * Version 1: Extended schema (id, hash, created_at, name, applied_at)\n */\nexport async function upgradeIfNeeded(\n\tmigrationsSchema: string,\n\tmigrationsTable: string,\n\tsession:\n\t\t| PgAsyncSession\n\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\tlocalMigrations: MigrationMeta[],\n): Promise<UpgradeResult> {\n\t// Check if the table exists at all\n\tconst result = await execute<{ '1': 1 }[]>(\n\t\tsession,\n\t\tsql`SELECT 1 FROM information_schema.tables\n\t\t\tWHERE table_schema = ${migrationsSchema}\n\t\t\tAND table_name = ${migrationsTable}`,\n\t);\n\n\tif (result.length === 0) {\n\t\treturn { newDb: true };\n\t}\n\n\t// Table exists, check table shape\n\tconst rows = await execute<\n\t\t{ schema: string; table_name: string; column_name: string; type: string }[]\n\t>(\n\t\tsession,\n\t\tsql`SELECT\n\t\t\tn.nspname AS \"schema\",\n\t\t\tc.relname AS \"table_name\",\n\t\t\ta.attname AS \"column_name\",\n\t\t\tpg_catalog.format_type(a.atttypid, a.atttypmod) AS \"type\"\n\t\tFROM\n\t\t\tpg_catalog.pg_attribute a\n\t\t\tJOIN pg_catalog.pg_class c ON c.oid = a.attrelid\n\t\t\tJOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n\t\tWHERE\n\t\t\ta.attnum > 0\n\t\t\tAND NOT a.attisdropped\n\t\t\tAND n.nspname = ${migrationsSchema}\n\t\t\tAND c.relname = ${migrationsTable}\n\t\tORDER BY a.attnum;`,\n\t);\n\n\tlet version = getVersion(rows.map((r) => r.column_name));\n\n\tfor (let v = version; v < CURRENT_MIGRATION_TABLE_VERSION; v++) {\n\t\tconst upgradeFn = upgradeFunctions[v];\n\t\tif (!upgradeFn) {\n\t\t\tthrow new Error(`No upgrade path from migration table version ${v} to ${v + 1}`);\n\t\t}\n\t\tawait upgradeFn(migrationsSchema, migrationsTable, session, localMigrations);\n\t}\n\n\treturn { prevVersion: version, currentVersion: CURRENT_MIGRATION_TABLE_VERSION };\n}\n"],"mappings":";;;;AAQA,MAAM,kCAAkC;AAQxC,SAAS,WAAW,SAAmB;AACtC,KAAI,QAAQ,SAAS,OAAO,CAAE,QAAO;AACrC,QAAO;;AAMR,eAAe,QACd,SAIA,OACa;CACb,MAAMA,SAA0B,MAAM,QAAQ,QAAQC,MAAI;AAC1D,KAAI,UAAU,OAAQ,QAAO,OAAO;AACpC,QAAO;;;;;;AAOR,MAAMC,mBAWF,EAUH,GAAG,OAAO,kBAAkB,iBAAiB,SAAS,oBAAoB;CACzE,MAAM,QAAQ,gBAAG,GAAGD,iBAAI,WA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Q,SAAS,gBAAG,QAAQ;AAClC,QAAM,QAAQ,SAAS,gBAAG,eAAe,MAAM,uCAAuC;AACtF,QAAM,QACL,SACA,gBAAG,eAAe,MAAM,+EACxB;AAED,OAAK,MAAM,iBAAiB,QAC3B,OAAM,QACL,SACA,gBAAG,UAAU,MAAM,cAAc,cAAc,KAAK,iCAAiC,cAAc,KACnG;AAEF,QAAM,QAAQ,SAAS,gBAAG,SAAS;UAC3BC,KAAU;AAClB,QAAM,QAAQ,SAAS,gBAAG,WAAW;AACrC,QAAM;;GAGR;;;;;;;AAQD,eAAsB,gBACrB,kBACA,iBACA,SAIA,iBACyB;AASzB,MAPe,MAAM,QACpB,SACA,gBAAG;0BACqB,iBAAiB;sBACrB,kBACpB,EAEU,WAAW,EACrB,QAAO,EAAE,OAAO,MAAM;CAyBvB,IAAI,UAAU,YArBD,MAAM,QAGlB,SACA,gBAAG;;;;;;;;;;;;qBAYgB,iBAAiB;qBACjB,gBAAgB;sBAEnC,EAE6B,KAAK,MAAM,EAAE,YAAY,CAAC;AAExD,MAAK,IAAI,IAAI,SAAS,IAAI,iCAAiC,KAAK;EAC/D,MAAM,YAAY,iBAAiB;AACnC,MAAI,CAAC,UACJ,OAAM,IAAI,MAAM,gDAAgD,EAAE,MAAM,IAAI,IAAI;AAEjF,QAAM,UAAU,kBAAkB,iBAAiB,SAAS,gBAAgB;;AAG7E,QAAO;EAAE,aAAa;EAAS,gBAAgB;EAAiC"}
|
|
1
|
+
{"version":3,"file":"pg.cjs","names":["result: { rows: T } | T","sql","upgradeFunctions: Record<\n\tnumber,\n\t(\n\t\tmigrationsSchema: string,\n\t\tmigrationsTable: string,\n\t\tsession:\n\t\t\t| PgAsyncSession\n\t\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\t\tlocalMigrations: MigrationMeta[],\n\t) => Promise<void>\n>","toApply: { id: number; name: string }[]","unmatchedIds: number[]","matched: MigrationMeta | undefined","err: any"],"sources":["../../src/up-migrations/pg.ts"],"sourcesContent":["import type { TablesRelationalConfig } from '~/_relations.ts';\nimport type { MigrationMeta } from '~/migrator.ts';\nimport type { NeonHttpSession } from '~/neon-http/session.ts';\nimport type { PgAsyncSession } from '~/pg-core/async/session.ts';\nimport type { AnyRelations } from '~/relations.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\nimport type { XataHttpSession } from '~/xata-http/session.ts';\n\nconst CURRENT_MIGRATION_TABLE_VERSION = 1;\n\ninterface UpgradeResult {\n\tnewDb?: boolean;\n\tprevVersion?: number;\n\tcurrentVersion?: number;\n}\n\nfunction getVersion(columns: string[]) {\n\tif (columns.includes('name')) return 1;\n\treturn 0;\n}\n\n// postgres.js returns array of objects\n// pg-proxy returns arrays of objects\n// node-postgres returns { rows: array of objects }\nasync function execute<T extends any[]>(\n\tsession:\n\t\t| PgAsyncSession\n\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\tsql: SQL,\n): Promise<T> {\n\tconst result: { rows: T } | T = await session.execute(sql);\n\tif ('rows' in result) return result.rows;\n\treturn result;\n}\n\n/**\n * Map of upgrade functions. Each key is the version being upgraded FROM,\n * and the function upgrades the table to the next version.\n */\nconst upgradeFunctions: Record<\n\tnumber,\n\t(\n\t\tmigrationsSchema: string,\n\t\tmigrationsTable: string,\n\t\tsession:\n\t\t\t| PgAsyncSession\n\t\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\t\tlocalMigrations: MigrationMeta[],\n\t) => Promise<void>\n> = {\n\t/**\n\t * Upgrade from version 0 to version 1:\n\t * 1. Read all existing DB migrations\n\t * 2. Sort localMigrations ASC by millis and if the same - sort by name\n\t * 3. Match each DB row to a local migration and backfill name\n\t * If multiple migrations share the same second, use hash matching as a tiebreaker\n\t * Not implemented for now -> If hash matching fails, fall back to serial id ordering\n\t * 5. Create extra column and backfill names for matched migrations\n\t */\n\t0: async (migrationsSchema, migrationsTable, session, localMigrations) => {\n\t\tconst table = sql`${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)}`;\n\n\t\t// 1. Read all existing DB migrations\n\t\t// Sort them by ids asc (order how they were applied)\n\t\tconst dbRows = await execute<{ id: number; hash: string; created_at: string }[]>(\n\t\t\tsession,\n\t\t\tsql`SELECT id, hash, created_at FROM ${table} ORDER BY id ASC`,\n\t\t);\n\n\t\tif (dbRows.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// 2. Sort ASC by millis and if the same - sort by name\n\t\tlocalMigrations.sort((a, b) =>\n\t\t\ta.folderMillis !== b.folderMillis ? a.folderMillis - b.folderMillis : (a.name ?? '').localeCompare(b.name ?? '')\n\t\t);\n\n\t\tconst byMillis = new Map<number, MigrationMeta[]>();\n\t\tconst byHash = new Map<string, MigrationMeta>();\n\t\tfor (const lm of localMigrations) {\n\t\t\tif (!byMillis.has(lm.folderMillis)) {\n\t\t\t\tbyMillis.set(lm.folderMillis, []);\n\t\t\t}\n\t\t\tbyMillis.get(lm.folderMillis)!.push(lm);\n\t\t\tbyHash.set(lm.hash, lm);\n\t\t}\n\n\t\t// \t3. Match each DB row to a local migration and backfill name\n\t\t// \tPriority: millis -> hash\n\t\tconst toApply: { id: number; name: string }[] = [];\n\t\tlet unmatchedIds: number[] = [];\n\n\t\tfor (const dbRow of dbRows) {\n\t\t\tconst stringified = String(dbRow.created_at);\n\t\t\tconst millis = Number(stringified.substring(0, stringified.length - 3) + '000');\n\t\t\tconst candidates = byMillis.get(millis);\n\n\t\t\tlet matched: MigrationMeta | undefined;\n\n\t\t\tif (candidates && candidates.length === 1) {\n\t\t\t\tmatched = candidates[0];\n\t\t\t} else if (candidates && candidates.length > 1) {\n\t\t\t\tmatched = candidates.find((c) => c.hash === dbRow.hash);\n\t\t\t} else {\n\t\t\t\tmatched = byHash.get(dbRow.hash);\n\t\t\t}\n\n\t\t\tif (matched) toApply.push({ id: dbRow.id, name: matched.name });\n\t\t\telse unmatchedIds.push(dbRow.id);\n\t\t}\n\n\t\t// 4. Check for unmatched\n\t\t// Out assumption on this migration flow is that all DB entries should be matched to a local migration\n\t\t// (if same seconds - fallback to hash, if hash fails - corner case)\n\t\t// If there are unmatched entries, it means that the local environment is missing migrations that have been applied to the DB,\n\t\t// which can lead to inconsistencies and potential issues when running future migrations\n\t\tif (unmatchedIds.length > 0) {\n\t\t\tconsole.log(\n\t\t\t\t`Error: While upgrading your database migrations table we found ${unmatchedIds.length} migrations (ids: ${\n\t\t\t\t\tunmatchedIds.join(', ')\n\t\t\t\t}) in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\t// 5. Create extra column and backfill names for matched migrations\n\t\ttry {\n\t\t\tawait execute(session, sql`BEGIN`);\n\t\t\tawait execute(session, sql`ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS \"name\" text`);\n\t\t\tawait execute(\n\t\t\t\tsession,\n\t\t\t\tsql`ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS \"applied_at\" timestamp with time zone DEFAULT now()`,\n\t\t\t);\n\n\t\t\tfor (const backfillEntry of toApply) {\n\t\t\t\tawait execute(\n\t\t\t\t\tsession,\n\t\t\t\t\tsql`UPDATE ${table} SET name = ${backfillEntry.name}, applied_at = NULL WHERE id = ${backfillEntry.id}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait execute(session, sql`COMMIT`);\n\t\t} catch (err: any) {\n\t\t\tawait execute(session, sql`ROLLBACK`);\n\t\t\tthrow err;\n\t\t}\n\t},\n};\n\n/**\n * Detects the current version of the migrations table schema and upgrades it if needed.\n *\n * Version 0: Original schema (id, hash, created_at)\n * Version 1: Extended schema (id, hash, created_at, name, applied_at)\n */\nexport async function upgradeIfNeeded(\n\tmigrationsSchema: string,\n\tmigrationsTable: string,\n\tsession:\n\t\t| PgAsyncSession\n\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\tlocalMigrations: MigrationMeta[],\n): Promise<UpgradeResult> {\n\t// Check if the table exists at all\n\tconst result = await execute<{ '1': 1 }[]>(\n\t\tsession,\n\t\tsql`SELECT 1 FROM information_schema.tables\n\t\t\tWHERE table_schema = ${migrationsSchema}\n\t\t\tAND table_name = ${migrationsTable}`,\n\t);\n\n\tif (result.length === 0) {\n\t\treturn { newDb: true };\n\t}\n\n\t// Table exists, check table shape\n\tconst rows = await execute<\n\t\t{ schema: string; table_name: string; column_name: string; type: string }[]\n\t>(\n\t\tsession,\n\t\tsql`SELECT\n\t\t\tn.nspname AS \"schema\",\n\t\t\tc.relname AS \"table_name\",\n\t\t\ta.attname AS \"column_name\",\n\t\t\tpg_catalog.format_type(a.atttypid, a.atttypmod) AS \"type\"\n\t\tFROM\n\t\t\tpg_catalog.pg_attribute a\n\t\t\tJOIN pg_catalog.pg_class c ON c.oid = a.attrelid\n\t\t\tJOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n\t\tWHERE\n\t\t\ta.attnum > 0\n\t\t\tAND NOT a.attisdropped\n\t\t\tAND n.nspname = ${migrationsSchema}\n\t\t\tAND c.relname = ${migrationsTable}\n\t\tORDER BY a.attnum;`,\n\t);\n\n\tlet version = getVersion(rows.map((r) => r.column_name));\n\n\tfor (let v = version; v < CURRENT_MIGRATION_TABLE_VERSION; v++) {\n\t\tconst upgradeFn = upgradeFunctions[v];\n\t\tif (!upgradeFn) {\n\t\t\tthrow new Error(`No upgrade path from migration table version ${v} to ${v + 1}`);\n\t\t}\n\t\tawait upgradeFn(migrationsSchema, migrationsTable, session, localMigrations);\n\t}\n\n\treturn { prevVersion: version, currentVersion: CURRENT_MIGRATION_TABLE_VERSION };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AE,aAAa;EAAS,gBAAgB;EAAiC"}
|
package/up-migrations/pg.js
CHANGED
|
@@ -44,7 +44,7 @@ const upgradeFunctions = { 0: async (migrationsSchema, migrationsTable, session,
|
|
|
44
44
|
else unmatchedIds.push(dbRow.id);
|
|
45
45
|
}
|
|
46
46
|
if (unmatchedIds.length > 0) {
|
|
47
|
-
console.log(`Error:
|
|
47
|
+
console.log(`Error: While upgrading your database migrations table we found ${unmatchedIds.length} migrations (ids: ${unmatchedIds.join(", ")}) in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`);
|
|
48
48
|
process.exit(1);
|
|
49
49
|
}
|
|
50
50
|
try {
|
package/up-migrations/pg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg.js","names":["result: { rows: T } | T","sql","upgradeFunctions: Record<\n\tnumber,\n\t(\n\t\tmigrationsSchema: string,\n\t\tmigrationsTable: string,\n\t\tsession:\n\t\t\t| PgAsyncSession\n\t\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\t\tlocalMigrations: MigrationMeta[],\n\t) => Promise<void>\n>","toApply: { id: number; name: string }[]","unmatchedIds: number[]","matched: MigrationMeta | undefined","err: any"],"sources":["../../src/up-migrations/pg.ts"],"sourcesContent":["import type { TablesRelationalConfig } from '~/_relations.ts';\nimport type { MigrationMeta } from '~/migrator.ts';\nimport type { NeonHttpSession } from '~/neon-http/session.ts';\nimport type { PgAsyncSession } from '~/pg-core/async/session.ts';\nimport type { AnyRelations } from '~/relations.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\nimport type { XataHttpSession } from '~/xata-http/session.ts';\n\nconst CURRENT_MIGRATION_TABLE_VERSION = 1;\n\ninterface UpgradeResult {\n\tnewDb?: boolean;\n\tprevVersion?: number;\n\tcurrentVersion?: number;\n}\n\nfunction getVersion(columns: string[]) {\n\tif (columns.includes('name')) return 1;\n\treturn 0;\n}\n\n// postgres.js returns array of objects\n// pg-proxy returns arrays of objects\n// node-postgres returns { rows: array of objects }\nasync function execute<T extends any[]>(\n\tsession:\n\t\t| PgAsyncSession\n\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\tsql: SQL,\n): Promise<T> {\n\tconst result: { rows: T } | T = await session.execute(sql);\n\tif ('rows' in result) return result.rows;\n\treturn result;\n}\n\n/**\n * Map of upgrade functions. Each key is the version being upgraded FROM,\n * and the function upgrades the table to the next version.\n */\nconst upgradeFunctions: Record<\n\tnumber,\n\t(\n\t\tmigrationsSchema: string,\n\t\tmigrationsTable: string,\n\t\tsession:\n\t\t\t| PgAsyncSession\n\t\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\t\tlocalMigrations: MigrationMeta[],\n\t) => Promise<void>\n> = {\n\t/**\n\t * Upgrade from version 0 to version 1:\n\t * 1. Read all existing DB migrations\n\t * 2. Sort localMigrations ASC by millis and if the same - sort by name\n\t * 3. Match each DB row to a local migration and backfill name\n\t * If multiple migrations share the same second, use hash matching as a tiebreaker\n\t * Not implemented for now -> If hash matching fails, fall back to serial id ordering\n\t * 5. Create extra column and backfill names for matched migrations\n\t */\n\t0: async (migrationsSchema, migrationsTable, session, localMigrations) => {\n\t\tconst table = sql`${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)}`;\n\n\t\t// 1. Read all existing DB migrations\n\t\t// Sort them by ids asc (order how they were applied)\n\t\tconst dbRows = await execute<{ id: number; hash: string; created_at: string }[]>(\n\t\t\tsession,\n\t\t\tsql`SELECT id, hash, created_at FROM ${table} ORDER BY id ASC`,\n\t\t);\n\n\t\tif (dbRows.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// 2. Sort ASC by millis and if the same - sort by name\n\t\tlocalMigrations.sort((a, b) =>\n\t\t\ta.folderMillis !== b.folderMillis ? a.folderMillis - b.folderMillis : (a.name ?? '').localeCompare(b.name ?? '')\n\t\t);\n\n\t\tconst byMillis = new Map<number, MigrationMeta[]>();\n\t\tconst byHash = new Map<string, MigrationMeta>();\n\t\tfor (const lm of localMigrations) {\n\t\t\tif (!byMillis.has(lm.folderMillis)) {\n\t\t\t\tbyMillis.set(lm.folderMillis, []);\n\t\t\t}\n\t\t\tbyMillis.get(lm.folderMillis)!.push(lm);\n\t\t\tbyHash.set(lm.hash, lm);\n\t\t}\n\n\t\t// \t3. Match each DB row to a local migration and backfill name\n\t\t// \tPriority: millis -> hash\n\t\tconst toApply: { id: number; name: string }[] = [];\n\t\tlet unmatchedIds: number[] = [];\n\n\t\tfor (const dbRow of dbRows) {\n\t\t\tconst stringified = String(dbRow.created_at);\n\t\t\tconst millis = Number(stringified.substring(0, stringified.length - 3) + '000');\n\t\t\tconst candidates = byMillis.get(millis);\n\n\t\t\tlet matched: MigrationMeta | undefined;\n\n\t\t\tif (candidates && candidates.length === 1) {\n\t\t\t\tmatched = candidates[0];\n\t\t\t} else if (candidates && candidates.length > 1) {\n\t\t\t\tmatched = candidates.find((c) => c.hash === dbRow.hash);\n\t\t\t} else {\n\t\t\t\tmatched = byHash.get(dbRow.hash);\n\t\t\t}\n\n\t\t\tif (matched) toApply.push({ id: dbRow.id, name: matched.name });\n\t\t\telse unmatchedIds.push(dbRow.id);\n\t\t}\n\n\t\t// 4. Check for unmatched\n\t\t// Out assumption on this migration flow is that all DB entries should be matched to a local migration\n\t\t// (if same seconds - fallback to hash, if hash fails - corner case)\n\t\t// If there are unmatched entries, it means that the local environment is missing migrations that have been applied to the DB,\n\t\t// which can lead to inconsistencies and potential issues when running future migrations\n\t\tif (unmatchedIds.length > 0) {\n\t\t\tconsole.log(\n\t\t\t\t`Error: Found ${unmatchedIds.length} migrations (ids: ${\n\t\t\t\t\tunmatchedIds.join(', ')\n\t\t\t\t}) in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\t// 5. Create extra column and backfill names for matched migrations\n\t\ttry {\n\t\t\tawait execute(session, sql`BEGIN`);\n\t\t\tawait execute(session, sql`ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS \"name\" text`);\n\t\t\tawait execute(\n\t\t\t\tsession,\n\t\t\t\tsql`ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS \"applied_at\" timestamp with time zone DEFAULT now()`,\n\t\t\t);\n\n\t\t\tfor (const backfillEntry of toApply) {\n\t\t\t\tawait execute(\n\t\t\t\t\tsession,\n\t\t\t\t\tsql`UPDATE ${table} SET name = ${backfillEntry.name}, applied_at = NULL WHERE id = ${backfillEntry.id}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait execute(session, sql`COMMIT`);\n\t\t} catch (err: any) {\n\t\t\tawait execute(session, sql`ROLLBACK`);\n\t\t\tthrow err;\n\t\t}\n\t},\n};\n\n/**\n * Detects the current version of the migrations table schema and upgrades it if needed.\n *\n * Version 0: Original schema (id, hash, created_at)\n * Version 1: Extended schema (id, hash, created_at, name, applied_at)\n */\nexport async function upgradeIfNeeded(\n\tmigrationsSchema: string,\n\tmigrationsTable: string,\n\tsession:\n\t\t| PgAsyncSession\n\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\tlocalMigrations: MigrationMeta[],\n): Promise<UpgradeResult> {\n\t// Check if the table exists at all\n\tconst result = await execute<{ '1': 1 }[]>(\n\t\tsession,\n\t\tsql`SELECT 1 FROM information_schema.tables\n\t\t\tWHERE table_schema = ${migrationsSchema}\n\t\t\tAND table_name = ${migrationsTable}`,\n\t);\n\n\tif (result.length === 0) {\n\t\treturn { newDb: true };\n\t}\n\n\t// Table exists, check table shape\n\tconst rows = await execute<\n\t\t{ schema: string; table_name: string; column_name: string; type: string }[]\n\t>(\n\t\tsession,\n\t\tsql`SELECT\n\t\t\tn.nspname AS \"schema\",\n\t\t\tc.relname AS \"table_name\",\n\t\t\ta.attname AS \"column_name\",\n\t\t\tpg_catalog.format_type(a.atttypid, a.atttypmod) AS \"type\"\n\t\tFROM\n\t\t\tpg_catalog.pg_attribute a\n\t\t\tJOIN pg_catalog.pg_class c ON c.oid = a.attrelid\n\t\t\tJOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n\t\tWHERE\n\t\t\ta.attnum > 0\n\t\t\tAND NOT a.attisdropped\n\t\t\tAND n.nspname = ${migrationsSchema}\n\t\t\tAND c.relname = ${migrationsTable}\n\t\tORDER BY a.attnum;`,\n\t);\n\n\tlet version = getVersion(rows.map((r) => r.column_name));\n\n\tfor (let v = version; v < CURRENT_MIGRATION_TABLE_VERSION; v++) {\n\t\tconst upgradeFn = upgradeFunctions[v];\n\t\tif (!upgradeFn) {\n\t\t\tthrow new Error(`No upgrade path from migration table version ${v} to ${v + 1}`);\n\t\t}\n\t\tawait upgradeFn(migrationsSchema, migrationsTable, session, localMigrations);\n\t}\n\n\treturn { prevVersion: version, currentVersion: CURRENT_MIGRATION_TABLE_VERSION };\n}\n"],"mappings":";;;AAQA,MAAM,kCAAkC;AAQxC,SAAS,WAAW,SAAmB;AACtC,KAAI,QAAQ,SAAS,OAAO,CAAE,QAAO;AACrC,QAAO;;AAMR,eAAe,QACd,SAIA,OACa;CACb,MAAMA,SAA0B,MAAM,QAAQ,QAAQC,MAAI;AAC1D,KAAI,UAAU,OAAQ,QAAO,OAAO;AACpC,QAAO;;;;;;AAOR,MAAMC,mBAWF,EAUH,GAAG,OAAO,kBAAkB,iBAAiB,SAAS,oBAAoB;CACzE,MAAM,QAAQ,GAAG,GAAG,IAAI,WAAW,iBAAiB,CAAC,GAAG,IAAI,WAAW,gBAAgB;CAIvF,MAAM,SAAS,MAAM,QACpB,SACA,GAAG,oCAAoC,MAAM,k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Ae,MAAM,+EACxB;AAED,OAAK,MAAM,iBAAiB,QAC3B,OAAM,QACL,SACA,GAAG,UAAU,MAAM,cAAc,cAAc,KAAK,iCAAiC,cAAc,KACnG;AAEF,QAAM,QAAQ,SAAS,GAAG,SAAS;UAC3BC,KAAU;AAClB,QAAM,QAAQ,SAAS,GAAG,WAAW;AACrC,QAAM;;GAGR;;;;;;;AAQD,eAAsB,gBACrB,kBACA,iBACA,SAIA,iBACyB;AASzB,MAPe,MAAM,QACpB,SACA,GAAG;0BACqB,iBAAiB;sBACrB,kBACpB,EAEU,WAAW,EACrB,QAAO,EAAE,OAAO,MAAM;CAyBvB,IAAI,UAAU,YArBD,MAAM,QAGlB,SACA,GAAG;;;;;;;;;;;;qBAYgB,iBAAiB;qBACjB,gBAAgB;sBAEnC,EAE6B,KAAK,MAAM,EAAE,YAAY,CAAC;AAExD,MAAK,IAAI,IAAI,SAAS,IAAI,iCAAiC,KAAK;EAC/D,MAAM,YAAY,iBAAiB;AACnC,MAAI,CAAC,UACJ,OAAM,IAAI,MAAM,gDAAgD,EAAE,MAAM,IAAI,IAAI;AAEjF,QAAM,UAAU,kBAAkB,iBAAiB,SAAS,gBAAgB;;AAG7E,QAAO;EAAE,aAAa;EAAS,gBAAgB;EAAiC"}
|
|
1
|
+
{"version":3,"file":"pg.js","names":["result: { rows: T } | T","sql","upgradeFunctions: Record<\n\tnumber,\n\t(\n\t\tmigrationsSchema: string,\n\t\tmigrationsTable: string,\n\t\tsession:\n\t\t\t| PgAsyncSession\n\t\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\t\tlocalMigrations: MigrationMeta[],\n\t) => Promise<void>\n>","toApply: { id: number; name: string }[]","unmatchedIds: number[]","matched: MigrationMeta | undefined","err: any"],"sources":["../../src/up-migrations/pg.ts"],"sourcesContent":["import type { TablesRelationalConfig } from '~/_relations.ts';\nimport type { MigrationMeta } from '~/migrator.ts';\nimport type { NeonHttpSession } from '~/neon-http/session.ts';\nimport type { PgAsyncSession } from '~/pg-core/async/session.ts';\nimport type { AnyRelations } from '~/relations.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\nimport type { XataHttpSession } from '~/xata-http/session.ts';\n\nconst CURRENT_MIGRATION_TABLE_VERSION = 1;\n\ninterface UpgradeResult {\n\tnewDb?: boolean;\n\tprevVersion?: number;\n\tcurrentVersion?: number;\n}\n\nfunction getVersion(columns: string[]) {\n\tif (columns.includes('name')) return 1;\n\treturn 0;\n}\n\n// postgres.js returns array of objects\n// pg-proxy returns arrays of objects\n// node-postgres returns { rows: array of objects }\nasync function execute<T extends any[]>(\n\tsession:\n\t\t| PgAsyncSession\n\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\tsql: SQL,\n): Promise<T> {\n\tconst result: { rows: T } | T = await session.execute(sql);\n\tif ('rows' in result) return result.rows;\n\treturn result;\n}\n\n/**\n * Map of upgrade functions. Each key is the version being upgraded FROM,\n * and the function upgrades the table to the next version.\n */\nconst upgradeFunctions: Record<\n\tnumber,\n\t(\n\t\tmigrationsSchema: string,\n\t\tmigrationsTable: string,\n\t\tsession:\n\t\t\t| PgAsyncSession\n\t\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\t\tlocalMigrations: MigrationMeta[],\n\t) => Promise<void>\n> = {\n\t/**\n\t * Upgrade from version 0 to version 1:\n\t * 1. Read all existing DB migrations\n\t * 2. Sort localMigrations ASC by millis and if the same - sort by name\n\t * 3. Match each DB row to a local migration and backfill name\n\t * If multiple migrations share the same second, use hash matching as a tiebreaker\n\t * Not implemented for now -> If hash matching fails, fall back to serial id ordering\n\t * 5. Create extra column and backfill names for matched migrations\n\t */\n\t0: async (migrationsSchema, migrationsTable, session, localMigrations) => {\n\t\tconst table = sql`${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)}`;\n\n\t\t// 1. Read all existing DB migrations\n\t\t// Sort them by ids asc (order how they were applied)\n\t\tconst dbRows = await execute<{ id: number; hash: string; created_at: string }[]>(\n\t\t\tsession,\n\t\t\tsql`SELECT id, hash, created_at FROM ${table} ORDER BY id ASC`,\n\t\t);\n\n\t\tif (dbRows.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// 2. Sort ASC by millis and if the same - sort by name\n\t\tlocalMigrations.sort((a, b) =>\n\t\t\ta.folderMillis !== b.folderMillis ? a.folderMillis - b.folderMillis : (a.name ?? '').localeCompare(b.name ?? '')\n\t\t);\n\n\t\tconst byMillis = new Map<number, MigrationMeta[]>();\n\t\tconst byHash = new Map<string, MigrationMeta>();\n\t\tfor (const lm of localMigrations) {\n\t\t\tif (!byMillis.has(lm.folderMillis)) {\n\t\t\t\tbyMillis.set(lm.folderMillis, []);\n\t\t\t}\n\t\t\tbyMillis.get(lm.folderMillis)!.push(lm);\n\t\t\tbyHash.set(lm.hash, lm);\n\t\t}\n\n\t\t// \t3. Match each DB row to a local migration and backfill name\n\t\t// \tPriority: millis -> hash\n\t\tconst toApply: { id: number; name: string }[] = [];\n\t\tlet unmatchedIds: number[] = [];\n\n\t\tfor (const dbRow of dbRows) {\n\t\t\tconst stringified = String(dbRow.created_at);\n\t\t\tconst millis = Number(stringified.substring(0, stringified.length - 3) + '000');\n\t\t\tconst candidates = byMillis.get(millis);\n\n\t\t\tlet matched: MigrationMeta | undefined;\n\n\t\t\tif (candidates && candidates.length === 1) {\n\t\t\t\tmatched = candidates[0];\n\t\t\t} else if (candidates && candidates.length > 1) {\n\t\t\t\tmatched = candidates.find((c) => c.hash === dbRow.hash);\n\t\t\t} else {\n\t\t\t\tmatched = byHash.get(dbRow.hash);\n\t\t\t}\n\n\t\t\tif (matched) toApply.push({ id: dbRow.id, name: matched.name });\n\t\t\telse unmatchedIds.push(dbRow.id);\n\t\t}\n\n\t\t// 4. Check for unmatched\n\t\t// Out assumption on this migration flow is that all DB entries should be matched to a local migration\n\t\t// (if same seconds - fallback to hash, if hash fails - corner case)\n\t\t// If there are unmatched entries, it means that the local environment is missing migrations that have been applied to the DB,\n\t\t// which can lead to inconsistencies and potential issues when running future migrations\n\t\tif (unmatchedIds.length > 0) {\n\t\t\tconsole.log(\n\t\t\t\t`Error: While upgrading your database migrations table we found ${unmatchedIds.length} migrations (ids: ${\n\t\t\t\t\tunmatchedIds.join(', ')\n\t\t\t\t}) in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\t// 5. Create extra column and backfill names for matched migrations\n\t\ttry {\n\t\t\tawait execute(session, sql`BEGIN`);\n\t\t\tawait execute(session, sql`ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS \"name\" text`);\n\t\t\tawait execute(\n\t\t\t\tsession,\n\t\t\t\tsql`ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS \"applied_at\" timestamp with time zone DEFAULT now()`,\n\t\t\t);\n\n\t\t\tfor (const backfillEntry of toApply) {\n\t\t\t\tawait execute(\n\t\t\t\t\tsession,\n\t\t\t\t\tsql`UPDATE ${table} SET name = ${backfillEntry.name}, applied_at = NULL WHERE id = ${backfillEntry.id}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait execute(session, sql`COMMIT`);\n\t\t} catch (err: any) {\n\t\t\tawait execute(session, sql`ROLLBACK`);\n\t\t\tthrow err;\n\t\t}\n\t},\n};\n\n/**\n * Detects the current version of the migrations table schema and upgrades it if needed.\n *\n * Version 0: Original schema (id, hash, created_at)\n * Version 1: Extended schema (id, hash, created_at, name, applied_at)\n */\nexport async function upgradeIfNeeded(\n\tmigrationsSchema: string,\n\tmigrationsTable: string,\n\tsession:\n\t\t| PgAsyncSession\n\t\t| NeonHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>\n\t\t| XataHttpSession<Record<string, unknown>, AnyRelations, TablesRelationalConfig>,\n\tlocalMigrations: MigrationMeta[],\n): Promise<UpgradeResult> {\n\t// Check if the table exists at all\n\tconst result = await execute<{ '1': 1 }[]>(\n\t\tsession,\n\t\tsql`SELECT 1 FROM information_schema.tables\n\t\t\tWHERE table_schema = ${migrationsSchema}\n\t\t\tAND table_name = ${migrationsTable}`,\n\t);\n\n\tif (result.length === 0) {\n\t\treturn { newDb: true };\n\t}\n\n\t// Table exists, check table shape\n\tconst rows = await execute<\n\t\t{ schema: string; table_name: string; column_name: string; type: string }[]\n\t>(\n\t\tsession,\n\t\tsql`SELECT\n\t\t\tn.nspname AS \"schema\",\n\t\t\tc.relname AS \"table_name\",\n\t\t\ta.attname AS \"column_name\",\n\t\t\tpg_catalog.format_type(a.atttypid, a.atttypmod) AS \"type\"\n\t\tFROM\n\t\t\tpg_catalog.pg_attribute a\n\t\t\tJOIN pg_catalog.pg_class c ON c.oid = a.attrelid\n\t\t\tJOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n\t\tWHERE\n\t\t\ta.attnum > 0\n\t\t\tAND NOT a.attisdropped\n\t\t\tAND n.nspname = ${migrationsSchema}\n\t\t\tAND c.relname = ${migrationsTable}\n\t\tORDER BY a.attnum;`,\n\t);\n\n\tlet version = getVersion(rows.map((r) => r.column_name));\n\n\tfor (let v = version; v < CURRENT_MIGRATION_TABLE_VERSION; v++) {\n\t\tconst upgradeFn = upgradeFunctions[v];\n\t\tif (!upgradeFn) {\n\t\t\tthrow new Error(`No upgrade path from migration table version ${v} to ${v + 1}`);\n\t\t}\n\t\tawait upgradeFn(migrationsSchema, migrationsTable, session, localMigrations);\n\t}\n\n\treturn { prevVersion: version, currentVersion: CURRENT_MIGRATION_TABLE_VERSION };\n}\n"],"mappings":";;;AAQA,MAAM,kCAAkC;AAQxC,SAAS,WAAW,SAAmB;AACtC,KAAI,QAAQ,SAAS,OAAO,CAAE,QAAO;AACrC,QA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migrator_ts5 from "../migrator.cjs";
|
|
3
3
|
import { MigrationConfig } from "../migrator.cjs";
|
|
4
4
|
import { AnyRelations } from "../relations.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/vercel-postgres/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: VercelPgDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: VercelPgDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts5.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { VercelPgDatabase } from "./driver.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __migrator_ts5 from "../migrator.js";
|
|
3
3
|
import { MigrationConfig } from "../migrator.js";
|
|
4
4
|
import { AnyRelations } from "../relations.js";
|
|
5
5
|
|
|
6
6
|
//#region src/vercel-postgres/migrator.d.ts
|
|
7
|
-
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: VercelPgDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void |
|
|
7
|
+
declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: VercelPgDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void | __migrator_ts5.MigratorInitFailResponse>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { migrate };
|
|
10
10
|
//# sourceMappingURL=migrator.d.ts.map
|