rwsdk 0.1.2-test.20250626055636 → 0.1.2
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/dist/runtime/lib/db/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/runtime/lib/db/typeInference/builders/alterColumn.d.ts +0 -12
- package/dist/runtime/lib/db/typeInference/builders/alterColumn.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +0 -21
- package/dist/runtime/lib/db/typeInference/builders/alterTable.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +0 -9
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +0 -14
- package/dist/runtime/lib/db/typeInference/builders/createTable.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/createView.d.ts +0 -13
- package/dist/runtime/lib/db/typeInference/builders/createView.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/dropTable.d.ts +0 -7
- package/dist/runtime/lib/db/typeInference/builders/dropTable.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/dropView.d.ts +0 -7
- package/dist/runtime/lib/db/typeInference/builders/dropView.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/schema.d.ts +0 -12
- package/dist/runtime/lib/db/typeInference/builders/schema.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/table.d.ts +0 -10
- package/dist/runtime/lib/db/typeInference/builders/table.js +0 -1
- package/dist/runtime/lib/db/typeInference/database.d.ts +0 -38
- package/dist/runtime/lib/db/typeInference/database.js +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.d.ts +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.js +0 -102
- package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.d.ts +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.js +0 -33
- package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.d.ts +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.js +0 -77
- package/dist/runtime/lib/db/typeInference/typetests/testUtils.d.ts +0 -2
- package/dist/runtime/lib/db/typeInference/typetests/testUtils.js +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.d.ts +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.js +0 -18
- package/dist/runtime/lib/db/typeInference/utils.d.ts +0 -14
- package/dist/runtime/lib/db/typeInference/utils.js +0 -1
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface AlterColumnBuilder {
|
|
2
|
-
setDataType<T extends string>(dataType: T): AlteredColumnBuilder<"setDataType", T>;
|
|
3
|
-
setDefault<T>(value: T): AlteredColumnBuilder<"setDefault", T>;
|
|
4
|
-
dropDefault(): AlteredColumnBuilder<"dropDefault", true>;
|
|
5
|
-
setNotNull(): AlteredColumnBuilder<"setNotNull", true>;
|
|
6
|
-
dropNotNull(): AlteredColumnBuilder<"dropNotNull", true>;
|
|
7
|
-
}
|
|
8
|
-
export interface AlteredColumnBuilder<Kind extends string, Value> {
|
|
9
|
-
readonly kind: Kind;
|
|
10
|
-
readonly value: Value;
|
|
11
|
-
}
|
|
12
|
-
export type AlterColumnBuilderCallback = (builder: AlterColumnBuilder) => AlteredColumnBuilder<any, any>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { SqlToTsType, ExecutedBuilder, Prettify } from "../utils";
|
|
2
|
-
import { ColumnDefinitionBuilder } from "./columnDefinition";
|
|
3
|
-
import { AlterColumnBuilderCallback } from "./alterColumn";
|
|
4
|
-
export interface AlterTableBuilder<TName extends string, TSchema extends Record<string, any> = {}> {
|
|
5
|
-
readonly __tableName: TName;
|
|
6
|
-
readonly __addedColumns: TSchema;
|
|
7
|
-
renameTo<TNewName extends string>(newTableName: TNewName): AlterTableBuilder<TNewName, TSchema>;
|
|
8
|
-
setSchema(newSchema: string): AlterTableBuilder<TName, TSchema>;
|
|
9
|
-
addColumn<K extends string, T extends string>(name: K, type: T, build?: (col: ColumnDefinitionBuilder<SqlToTsType<T>>) => ColumnDefinitionBuilder<SqlToTsType<T>>): AlterTableBuilder<TName, Prettify<TSchema & Record<K, SqlToTsType<T>>>>;
|
|
10
|
-
dropColumn<K extends string>(name: K): AlterTableBuilder<TName, Prettify<TSchema & {
|
|
11
|
-
[P in K]: never;
|
|
12
|
-
}>>;
|
|
13
|
-
renameColumn<KFrom extends string, KTo extends string>(from: KFrom, to: KTo): AlterTableBuilder<TName, Prettify<TSchema & {
|
|
14
|
-
[P in KFrom]: never;
|
|
15
|
-
} & {
|
|
16
|
-
[P in KTo]: any;
|
|
17
|
-
}>>;
|
|
18
|
-
alterColumn<K extends string>(column: K, alteration: AlterColumnBuilderCallback): AlterTableBuilder<TName, TSchema>;
|
|
19
|
-
modifyColumn<K extends string, T extends string>(column: K, type: T, build?: (col: ColumnDefinitionBuilder<SqlToTsType<T>>) => ColumnDefinitionBuilder<SqlToTsType<T>>): AlterTableBuilder<TName, Prettify<TSchema & Record<K, SqlToTsType<T>>>>;
|
|
20
|
-
execute(): ExecutedBuilder<this>;
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface ColumnDefinitionBuilder<T = any> {
|
|
2
|
-
primaryKey(): ColumnDefinitionBuilder<T>;
|
|
3
|
-
notNull(): ColumnDefinitionBuilder<T>;
|
|
4
|
-
unique(): ColumnDefinitionBuilder<T>;
|
|
5
|
-
defaultTo<V extends T>(value: V): ColumnDefinitionBuilder<T>;
|
|
6
|
-
references(ref: string): ColumnDefinitionBuilder<T>;
|
|
7
|
-
onDelete(action: "cascade" | "restrict" | "set null"): ColumnDefinitionBuilder<T>;
|
|
8
|
-
unsigned(): ColumnDefinitionBuilder<T>;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SqlToTsType, ExecutedBuilder, Prettify } from "../utils";
|
|
2
|
-
import { ColumnDefinitionBuilder } from "./columnDefinition";
|
|
3
|
-
export interface CreateTableBuilder<TName extends string, TSchema extends Record<string, any> = {}> {
|
|
4
|
-
readonly __tableName: TName;
|
|
5
|
-
readonly __addedColumns: TSchema;
|
|
6
|
-
temporary(): CreateTableBuilder<TName, TSchema>;
|
|
7
|
-
onCommit(onCommit: "preserve rows" | "delete rows" | "drop"): CreateTableBuilder<TName, TSchema>;
|
|
8
|
-
ifNotExists(): CreateTableBuilder<TName, TSchema>;
|
|
9
|
-
addColumn<K extends string, T extends string>(name: K, type: T, build?: (col: ColumnDefinitionBuilder<SqlToTsType<T>>) => ColumnDefinitionBuilder<SqlToTsType<T>>): CreateTableBuilder<TName, Prettify<TSchema & Record<K, SqlToTsType<T>>>>;
|
|
10
|
-
modifyFront(modifier: string): CreateTableBuilder<TName, TSchema>;
|
|
11
|
-
modifyEnd(modifier: string): CreateTableBuilder<TName, TSchema>;
|
|
12
|
-
as(expression: string): CreateTableBuilder<TName, TSchema>;
|
|
13
|
-
execute(): ExecutedBuilder<this>;
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ExecutedBuilder } from "../utils";
|
|
2
|
-
export interface CreateViewBuilder<TName extends string, TSchema extends Record<string, any> = {}, TColumns extends string[] = []> {
|
|
3
|
-
readonly __viewName: TName;
|
|
4
|
-
readonly __schema: TSchema;
|
|
5
|
-
readonly __columns: TColumns;
|
|
6
|
-
withSchema<S extends Record<string, any>>(): CreateViewBuilder<TName, S, TColumns>;
|
|
7
|
-
temporary(): CreateViewBuilder<TName, TSchema, TColumns>;
|
|
8
|
-
orReplace(): CreateViewBuilder<TName, TSchema, TColumns>;
|
|
9
|
-
ifNotExists(): CreateViewBuilder<TName, TSchema, TColumns>;
|
|
10
|
-
columns<C extends string[]>(columns: C): CreateViewBuilder<TName, TSchema, C>;
|
|
11
|
-
as<E extends string>(expression: E): CreateViewBuilder<TName, TSchema, TColumns>;
|
|
12
|
-
execute(): ExecutedBuilder<this>;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TableBuilder } from "./table";
|
|
2
|
-
import { AlterTableBuilder } from "./alterTable";
|
|
3
|
-
import { DropTableBuilder } from "./dropTable";
|
|
4
|
-
import { CreateViewBuilder } from "./createView";
|
|
5
|
-
import { DropViewBuilder } from "./dropView";
|
|
6
|
-
export interface SchemaBuilder {
|
|
7
|
-
createTable<TName extends string>(name: TName): TableBuilder<TName, {}>;
|
|
8
|
-
alterTable<TName extends string>(name: TName): AlterTableBuilder<TName, {}>;
|
|
9
|
-
dropTable<TName extends string>(name: TName): DropTableBuilder<TName>;
|
|
10
|
-
createView<TName extends string>(name: TName): CreateViewBuilder<TName, {}>;
|
|
11
|
-
dropView<TName extends string>(name: TName): DropViewBuilder<TName>;
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SqlToTsType, ExecutedBuilder, Prettify } from "../utils";
|
|
2
|
-
import { ColumnDefinitionBuilder } from "./columnDefinition";
|
|
3
|
-
export interface TableBuilder<TName extends string, TSchema extends Record<string, any> = {}> {
|
|
4
|
-
readonly __tableName: TName;
|
|
5
|
-
readonly __schema: TSchema;
|
|
6
|
-
addColumn<K extends string, T extends string>(name: K, type: T, build?: (col: ColumnDefinitionBuilder<SqlToTsType<T>>) => ColumnDefinitionBuilder<SqlToTsType<T>>): TableBuilder<TName, Prettify<TSchema & Record<K, SqlToTsType<T>>>>;
|
|
7
|
-
temporary(): this;
|
|
8
|
-
ifNotExists(): this;
|
|
9
|
-
execute(): ExecutedBuilder<this>;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Kysely } from "kysely";
|
|
2
|
-
import { ExecutedBuilder, Prettify, MergeSchemas, OmitNever, UnionToIntersection } from "./utils";
|
|
3
|
-
import { TableBuilder } from "./builders/table";
|
|
4
|
-
import { CreateViewBuilder } from "./builders/createView.js";
|
|
5
|
-
import { AlterTableBuilder } from "./builders/alterTable.js";
|
|
6
|
-
import { DropTableBuilder } from "./builders/dropTable.js";
|
|
7
|
-
import { DropViewBuilder } from "./builders/dropView.js";
|
|
8
|
-
import { SchemaBuilder } from "./builders/schema";
|
|
9
|
-
export interface InferenceBuilder {
|
|
10
|
-
schema: SchemaBuilder;
|
|
11
|
-
}
|
|
12
|
-
export type MigrationBuilder = InferenceBuilder & Kysely<any>;
|
|
13
|
-
export interface Migration<TUpReturn = unknown> {
|
|
14
|
-
up(db: MigrationBuilder): TUpReturn;
|
|
15
|
-
down?(db: Kysely<any>): any;
|
|
16
|
-
}
|
|
17
|
-
export type Migrations = Record<string, Migration>;
|
|
18
|
-
type GetBuilder<T> = T extends ExecutedBuilder<infer B> ? B : never;
|
|
19
|
-
type BuildersFromMigration<TMigration extends Migration> = TMigration extends Migration<infer TUpReturn> ? Awaited<TUpReturn> extends Array<infer Item> ? GetBuilder<Item> : GetBuilder<Awaited<TUpReturn>> : never;
|
|
20
|
-
type AllBuilders<TMigrations extends Migrations> = BuildersFromMigration<TMigrations[keyof TMigrations]>;
|
|
21
|
-
type CreatedTables<TMigrations extends Migrations> = UnionToIntersection<ExtractTableSchema<Extract<AllBuilders<TMigrations>, TableBuilder<any, any>>>>;
|
|
22
|
-
type CreatedViews<TMigrations extends Migrations> = UnionToIntersection<ExtractViewSchema<Extract<AllBuilders<TMigrations>, CreateViewBuilder<any, any>>>>;
|
|
23
|
-
type AlteredTables<TMigrations extends Migrations> = UnionToIntersection<ExtractAlterSchema<Extract<AllBuilders<TMigrations>, AlterTableBuilder<any, any>>>>;
|
|
24
|
-
type DroppedTableNames<TMigrations extends Migrations> = ExtractDroppedTableName<Extract<AllBuilders<TMigrations>, DropTableBuilder<any>>>;
|
|
25
|
-
type DroppedViewNames<TMigrations extends Migrations> = ExtractDroppedViewName<Extract<AllBuilders<TMigrations>, DropViewBuilder<any>>>;
|
|
26
|
-
type AllCreated<TMigrations extends Migrations> = MergeSchemas<CreatedTables<TMigrations>, CreatedViews<TMigrations>>;
|
|
27
|
-
type MergedSchemaBeforeDrop<TMigrations extends Migrations> = MergeSchemas<AllCreated<TMigrations>, AlteredTables<TMigrations>>;
|
|
28
|
-
type CleanedSchema<T> = {
|
|
29
|
-
[K in keyof T]: OmitNever<T[K]>;
|
|
30
|
-
};
|
|
31
|
-
type InferredDatabase<TMigrations extends Migrations> = Omit<Omit<CleanedSchema<MergedSchemaBeforeDrop<TMigrations>>, DroppedTableNames<TMigrations>>, DroppedViewNames<TMigrations>>;
|
|
32
|
-
export type Database<TMigrations extends Migrations = Migrations> = Prettify<InferredDatabase<TMigrations>>;
|
|
33
|
-
export type ExtractTableSchema<T> = T extends TableBuilder<infer TName, infer TSchema> ? Record<TName, TSchema> : never;
|
|
34
|
-
export type ExtractViewSchema<T> = T extends CreateViewBuilder<infer TName, infer TSchema> ? Record<TName, TSchema> : never;
|
|
35
|
-
export type ExtractAlterSchema<T> = T extends AlterTableBuilder<infer TName, infer TSchema> ? Record<TName, TSchema> : never;
|
|
36
|
-
export type ExtractDroppedTableName<T> = T extends DropTableBuilder<infer TName> ? TName : never;
|
|
37
|
-
export type ExtractDroppedViewName<T> = T extends DropViewBuilder<infer TName> ? TName : never;
|
|
38
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
(_it = "alterTable addColumn") => {
|
|
2
|
-
const migrations = {
|
|
3
|
-
"0": {
|
|
4
|
-
async up(db) {
|
|
5
|
-
return [
|
|
6
|
-
db.schema
|
|
7
|
-
.createTable("users")
|
|
8
|
-
.addColumn("username", "text", (col) => col.notNull().unique())
|
|
9
|
-
.execute(),
|
|
10
|
-
];
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
"1": {
|
|
14
|
-
async up(db) {
|
|
15
|
-
return [
|
|
16
|
-
db.schema
|
|
17
|
-
.alterTable("users")
|
|
18
|
-
.addColumn("displayName", "text")
|
|
19
|
-
.execute(),
|
|
20
|
-
];
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
(_test) => { };
|
|
25
|
-
};
|
|
26
|
-
(_it = "alterTable renameColumn and dropColumn") => {
|
|
27
|
-
const migrations = {
|
|
28
|
-
"0": {
|
|
29
|
-
async up(db) {
|
|
30
|
-
return [
|
|
31
|
-
db.schema
|
|
32
|
-
.createTable("users")
|
|
33
|
-
.addColumn("username", "text")
|
|
34
|
-
.addColumn("displayName", "text")
|
|
35
|
-
.execute(),
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
"1": {
|
|
40
|
-
async up(db) {
|
|
41
|
-
return [
|
|
42
|
-
db.schema
|
|
43
|
-
.alterTable("users")
|
|
44
|
-
.renameColumn("displayName", "nickname")
|
|
45
|
-
.dropColumn("username")
|
|
46
|
-
.execute(),
|
|
47
|
-
];
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
(_test) => { };
|
|
52
|
-
};
|
|
53
|
-
(_it = "alterTable alterColumn setDataType and setDefault") => {
|
|
54
|
-
const migrations = {
|
|
55
|
-
"0": {
|
|
56
|
-
async up(db) {
|
|
57
|
-
return [
|
|
58
|
-
db.schema.createTable("users").addColumn("age", "integer").execute(),
|
|
59
|
-
];
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
"1": {
|
|
63
|
-
async up(db) {
|
|
64
|
-
return [
|
|
65
|
-
db.schema
|
|
66
|
-
.alterTable("users")
|
|
67
|
-
.alterColumn("age", (col) => col.setDataType("text"))
|
|
68
|
-
.alterColumn("age", (col) => col.setDefault("unknown"))
|
|
69
|
-
.execute(),
|
|
70
|
-
];
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
// todo(justinvdm, 2024-01-08): Support setDataType()
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
(_test) => { };
|
|
77
|
-
};
|
|
78
|
-
(_it = "alterTable alterColumn dropDefault, setNotNull, dropNotNull") => {
|
|
79
|
-
const migrations = {
|
|
80
|
-
"0": {
|
|
81
|
-
async up(db) {
|
|
82
|
-
return [
|
|
83
|
-
db.schema.createTable("users").addColumn("age", "integer").execute(),
|
|
84
|
-
];
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
"1": {
|
|
88
|
-
async up(db) {
|
|
89
|
-
return [
|
|
90
|
-
db.schema
|
|
91
|
-
.alterTable("users")
|
|
92
|
-
.alterColumn("age", (col) => col.dropDefault())
|
|
93
|
-
.alterColumn("age", (col) => col.setNotNull())
|
|
94
|
-
.alterColumn("age", (col) => col.dropNotNull())
|
|
95
|
-
.execute(),
|
|
96
|
-
];
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
(_test) => { };
|
|
101
|
-
};
|
|
102
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
(_it = "createTable") => {
|
|
2
|
-
const migrations = {
|
|
3
|
-
"001_init": {
|
|
4
|
-
async up(db) {
|
|
5
|
-
return [
|
|
6
|
-
db.schema
|
|
7
|
-
.createTable("users")
|
|
8
|
-
.addColumn("username", "text", (col) => col.notNull().unique())
|
|
9
|
-
.execute(),
|
|
10
|
-
];
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
(_test) => { };
|
|
15
|
-
};
|
|
16
|
-
(_it = "createTable with multiple columns and defaults") => {
|
|
17
|
-
const migrations = {
|
|
18
|
-
"001_init": {
|
|
19
|
-
async up(db) {
|
|
20
|
-
return [
|
|
21
|
-
db.schema
|
|
22
|
-
.createTable("users")
|
|
23
|
-
.addColumn("username", "text", (col) => col.notNull())
|
|
24
|
-
.addColumn("age", "integer", (col) => col.defaultTo(18))
|
|
25
|
-
.addColumn("active", "boolean", (col) => col.defaultTo(true))
|
|
26
|
-
.execute(),
|
|
27
|
-
];
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
(_test) => { };
|
|
32
|
-
};
|
|
33
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
(_it = "dropTable") => {
|
|
2
|
-
const migrations = {
|
|
3
|
-
"0": {
|
|
4
|
-
async up(db) {
|
|
5
|
-
return [
|
|
6
|
-
db.schema
|
|
7
|
-
.createTable("users")
|
|
8
|
-
.addColumn("username", "text", (col) => col.notNull().unique())
|
|
9
|
-
.execute(),
|
|
10
|
-
db.schema.createTable("posts").addColumn("title", "text").execute(),
|
|
11
|
-
];
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
"1": {
|
|
15
|
-
async up(db) {
|
|
16
|
-
return [db.schema.dropTable("posts").execute()];
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
(_test) => { };
|
|
21
|
-
};
|
|
22
|
-
(_it = "dropTable non-existent table") => {
|
|
23
|
-
const migrations = {
|
|
24
|
-
"0": {
|
|
25
|
-
async up(db) {
|
|
26
|
-
return [db.schema.dropTable("ghost").execute()];
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
(_test) => { };
|
|
31
|
-
};
|
|
32
|
-
(_it = "dropTable all tables") => {
|
|
33
|
-
const migrations = {
|
|
34
|
-
"0": {
|
|
35
|
-
async up(db) {
|
|
36
|
-
return [
|
|
37
|
-
db.schema.createTable("a").addColumn("x", "text").execute(),
|
|
38
|
-
db.schema.createTable("b").addColumn("y", "text").execute(),
|
|
39
|
-
];
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
"1": {
|
|
43
|
-
async up(db) {
|
|
44
|
-
return [
|
|
45
|
-
db.schema.dropTable("a").execute(),
|
|
46
|
-
db.schema.dropTable("b").execute(),
|
|
47
|
-
];
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
(_test) => { };
|
|
52
|
-
};
|
|
53
|
-
(_it = "chaining createTable and dropTable") => {
|
|
54
|
-
const migrations = {
|
|
55
|
-
"0": {
|
|
56
|
-
async up(db) {
|
|
57
|
-
return [
|
|
58
|
-
db.schema
|
|
59
|
-
.createTable("users")
|
|
60
|
-
.addColumn("username", "text")
|
|
61
|
-
.execute(),
|
|
62
|
-
db.schema.createTable("posts").addColumn("title", "text").execute(),
|
|
63
|
-
];
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
"1": {
|
|
67
|
-
async up(db) {
|
|
68
|
-
return [
|
|
69
|
-
db.schema.dropTable("posts").execute(),
|
|
70
|
-
db.schema.createTable("comments").addColumn("text", "text").execute(),
|
|
71
|
-
];
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
(_test) => { };
|
|
76
|
-
};
|
|
77
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
(_it = "addColumn with default value") => {
|
|
2
|
-
const migrations = {
|
|
3
|
-
"0": {
|
|
4
|
-
async up(db) {
|
|
5
|
-
return [
|
|
6
|
-
db.schema
|
|
7
|
-
.createTable("users")
|
|
8
|
-
.addColumn("username", "text", (col) => col.notNull().unique())
|
|
9
|
-
.addColumn("posts", "integer", (col) => col.defaultTo(0).notNull())
|
|
10
|
-
.execute(),
|
|
11
|
-
];
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
(_test) => { };
|
|
16
|
-
};
|
|
17
|
-
export {};
|
|
18
|
-
// All tests for createTable, dropTable, and alterTable have been moved to their own files.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type SqlToTsType<T extends string> = T extends "text" ? string : T extends "integer" ? number : T extends "blob" ? Uint8Array : T extends "real" ? number : T extends "boolean" ? boolean : never;
|
|
2
|
-
export type Prettify<T> = {
|
|
3
|
-
[K in keyof T]: T[K];
|
|
4
|
-
} & {};
|
|
5
|
-
export type ExecutedBuilder<T> = Promise<void> & {
|
|
6
|
-
__builder_type: T;
|
|
7
|
-
};
|
|
8
|
-
export type MergeSchemas<A, B> = {
|
|
9
|
-
[K in keyof A | keyof B]: K extends keyof A ? K extends keyof B ? Prettify<A[K] & B[K]> : A[K] : K extends keyof B ? B[K] : never;
|
|
10
|
-
};
|
|
11
|
-
export type OmitNever<T> = {
|
|
12
|
-
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
13
|
-
};
|
|
14
|
-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|