kysely-schema 0.1.0
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/.turbo/turbo-build.log +20 -0
- package/dist/index.d.mts +207 -0
- package/dist/index.d.ts +207 -0
- package/dist/index.js +573 -0
- package/dist/index.mjs +535 -0
- package/package.json +48 -0
- package/src/differ/index.ts +150 -0
- package/src/differ/operations.ts +33 -0
- package/src/generators/migration.ts +172 -0
- package/src/generators/templates.ts +33 -0
- package/src/generators/types.ts +91 -0
- package/src/index.ts +40 -0
- package/src/schema/dsl.ts +125 -0
- package/src/schema/types.ts +158 -0
- package/src/schema/validators.ts +113 -0
- package/tests/differ.test.ts +161 -0
- package/tests/dsl.test.ts +168 -0
- package/tests/migration.test.ts +140 -0
- package/tests/types.test.ts +176 -0
- package/tests/validators.test.ts +116 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +9 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
> kysely-schema@0.1.0 build C:\Codes\node\2026\github\kysely-schema\packages\core
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.1
|
|
8
|
+
[34mCLI[39m Using tsup config: C:\Codes\node\2026\github\kysely-schema\packages\core\tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: es2022
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[34mCJS[39m Build start
|
|
13
|
+
[32mCJS[39m [1mdist\index.js [22m[32m18.21 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 41ms
|
|
15
|
+
[32mESM[39m [1mdist\index.mjs [22m[32m16.80 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 42ms
|
|
17
|
+
[34mDTS[39m Build start
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 655ms
|
|
19
|
+
[32mDTS[39m [1mdist\index.d.mts [22m[32m7.09 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist\index.d.ts [22m[32m7.09 KB[39m
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
type ReferentialAction = 'cascade' | 'set null' | 'restrict' | 'no action';
|
|
2
|
+
type ColumnType = 'serial' | 'integer' | 'bigint' | 'decimal' | 'text' | 'varchar' | 'timestamp' | 'date' | 'time' | 'boolean' | 'json' | 'jsonb' | 'binary' | 'uuid';
|
|
3
|
+
interface ForeignKeyReference {
|
|
4
|
+
table: string;
|
|
5
|
+
column: string;
|
|
6
|
+
}
|
|
7
|
+
interface ColumnDefinition {
|
|
8
|
+
type: ColumnType;
|
|
9
|
+
primaryKey?: boolean;
|
|
10
|
+
notNull?: boolean;
|
|
11
|
+
nullable?: boolean;
|
|
12
|
+
unique?: boolean;
|
|
13
|
+
default?: string | number | boolean;
|
|
14
|
+
references?: ForeignKeyReference;
|
|
15
|
+
onDelete?: ReferentialAction;
|
|
16
|
+
onUpdate?: ReferentialAction;
|
|
17
|
+
index?: boolean;
|
|
18
|
+
check?: string;
|
|
19
|
+
length?: number;
|
|
20
|
+
precision?: number;
|
|
21
|
+
scale?: number;
|
|
22
|
+
}
|
|
23
|
+
interface IndexDefinition {
|
|
24
|
+
name?: string;
|
|
25
|
+
columns: string[];
|
|
26
|
+
unique?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface TableDefinition {
|
|
29
|
+
columns: Record<string, ColumnDefinition>;
|
|
30
|
+
indexes: IndexDefinition[];
|
|
31
|
+
checks?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface SchemaDefinition {
|
|
34
|
+
tables: Record<string, TableDefinition>;
|
|
35
|
+
}
|
|
36
|
+
interface MigrationFile {
|
|
37
|
+
filename: string;
|
|
38
|
+
content: string;
|
|
39
|
+
}
|
|
40
|
+
type DiffOperationType = 'addTable' | 'dropTable' | 'addColumn' | 'dropColumn' | 'alterColumn' | 'addIndex' | 'dropIndex';
|
|
41
|
+
interface BaseDiffOperation {
|
|
42
|
+
type: DiffOperationType;
|
|
43
|
+
description: string;
|
|
44
|
+
}
|
|
45
|
+
interface AddTableOperation extends BaseDiffOperation {
|
|
46
|
+
type: 'addTable';
|
|
47
|
+
tableName: string;
|
|
48
|
+
table: TableDefinition;
|
|
49
|
+
}
|
|
50
|
+
interface DropTableOperation extends BaseDiffOperation {
|
|
51
|
+
type: 'dropTable';
|
|
52
|
+
tableName: string;
|
|
53
|
+
}
|
|
54
|
+
interface AddColumnOperation extends BaseDiffOperation {
|
|
55
|
+
type: 'addColumn';
|
|
56
|
+
tableName: string;
|
|
57
|
+
columnName: string;
|
|
58
|
+
column: ColumnDefinition;
|
|
59
|
+
}
|
|
60
|
+
interface DropColumnOperation extends BaseDiffOperation {
|
|
61
|
+
type: 'dropColumn';
|
|
62
|
+
tableName: string;
|
|
63
|
+
columnName: string;
|
|
64
|
+
}
|
|
65
|
+
interface AlterColumnOperation extends BaseDiffOperation {
|
|
66
|
+
type: 'alterColumn';
|
|
67
|
+
tableName: string;
|
|
68
|
+
columnName: string;
|
|
69
|
+
oldColumn: ColumnDefinition;
|
|
70
|
+
newColumn: ColumnDefinition;
|
|
71
|
+
}
|
|
72
|
+
interface AddIndexOperation extends BaseDiffOperation {
|
|
73
|
+
type: 'addIndex';
|
|
74
|
+
tableName: string;
|
|
75
|
+
index: IndexDefinition;
|
|
76
|
+
}
|
|
77
|
+
interface DropIndexOperation extends BaseDiffOperation {
|
|
78
|
+
type: 'dropIndex';
|
|
79
|
+
tableName: string;
|
|
80
|
+
indexName: string;
|
|
81
|
+
}
|
|
82
|
+
type DiffOperation = AddTableOperation | DropTableOperation | AddColumnOperation | DropColumnOperation | AlterColumnOperation | AddIndexOperation | DropIndexOperation;
|
|
83
|
+
interface SchemaSnapshot {
|
|
84
|
+
version: string;
|
|
85
|
+
timestamp: string;
|
|
86
|
+
schema: SchemaDefinition;
|
|
87
|
+
}
|
|
88
|
+
interface KyselySchemaConfig {
|
|
89
|
+
schemaPath: string;
|
|
90
|
+
migrationsDir: string;
|
|
91
|
+
generatedDir: string;
|
|
92
|
+
snapshotDir: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare class ColumnBuilder {
|
|
96
|
+
private def;
|
|
97
|
+
constructor(init: Partial<ColumnDefinition> & {
|
|
98
|
+
type: ColumnType;
|
|
99
|
+
});
|
|
100
|
+
primaryKey(): this;
|
|
101
|
+
notNull(): this;
|
|
102
|
+
nullable(): this;
|
|
103
|
+
unique(): this;
|
|
104
|
+
default(value: string | number | boolean): this;
|
|
105
|
+
references(table: string, col: string): this;
|
|
106
|
+
onDelete(action: ReferentialAction): this;
|
|
107
|
+
onUpdate(action: ReferentialAction): this;
|
|
108
|
+
index(): this;
|
|
109
|
+
check(expression: string): this;
|
|
110
|
+
/** @internal Return the raw column definition. */
|
|
111
|
+
build(): ColumnDefinition;
|
|
112
|
+
}
|
|
113
|
+
declare const column: {
|
|
114
|
+
serial: () => ColumnBuilder;
|
|
115
|
+
integer: () => ColumnBuilder;
|
|
116
|
+
bigint: () => ColumnBuilder;
|
|
117
|
+
decimal: (precision?: number, scale?: number) => ColumnBuilder;
|
|
118
|
+
text: () => ColumnBuilder;
|
|
119
|
+
varchar: (length?: number) => ColumnBuilder;
|
|
120
|
+
timestamp: () => ColumnBuilder;
|
|
121
|
+
date: () => ColumnBuilder;
|
|
122
|
+
time: () => ColumnBuilder;
|
|
123
|
+
boolean: () => ColumnBuilder;
|
|
124
|
+
json: () => ColumnBuilder;
|
|
125
|
+
jsonb: () => ColumnBuilder;
|
|
126
|
+
binary: () => ColumnBuilder;
|
|
127
|
+
uuid: () => ColumnBuilder;
|
|
128
|
+
};
|
|
129
|
+
declare function table(columns: Record<string, ColumnBuilder>): TableDefinition;
|
|
130
|
+
declare function defineSchema(tables: Record<string, TableDefinition>): SchemaDefinition;
|
|
131
|
+
|
|
132
|
+
interface ValidationError {
|
|
133
|
+
table: string;
|
|
134
|
+
column?: string;
|
|
135
|
+
message: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Validate a schema definition and return a list of problems.
|
|
139
|
+
* Returns an empty array if the schema is valid.
|
|
140
|
+
*/
|
|
141
|
+
declare function validateSchema(schema: SchemaDefinition): ValidationError[];
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Generates Kysely migration files from a SchemaDefinition.
|
|
145
|
+
*/
|
|
146
|
+
declare class MigrationGenerator {
|
|
147
|
+
/**
|
|
148
|
+
* Generate a full CREATE-TABLE migration for the entire schema.
|
|
149
|
+
*/
|
|
150
|
+
generate(schema: SchemaDefinition, migrationName: string): MigrationFile;
|
|
151
|
+
private generateUpFunction;
|
|
152
|
+
private generateCreateTable;
|
|
153
|
+
private generateColumnDefinition;
|
|
154
|
+
private buildModifiers;
|
|
155
|
+
private generateDownFunction;
|
|
156
|
+
private generateIndexes;
|
|
157
|
+
private mapColumnType;
|
|
158
|
+
private formatDefaultValue;
|
|
159
|
+
private generateTimestamp;
|
|
160
|
+
private sanitize;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Generates a TypeScript `Database` interface from a SchemaDefinition.
|
|
165
|
+
*/
|
|
166
|
+
declare class TypeGenerator {
|
|
167
|
+
generate(schema: SchemaDefinition): string;
|
|
168
|
+
private mapToTypeScript;
|
|
169
|
+
private baseTypeMap;
|
|
170
|
+
private toPascalCase;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Default schema template written by `kysely-schema init`.
|
|
175
|
+
*/
|
|
176
|
+
declare const schemaTemplate = "import { defineSchema, table, column } from 'kysely-schema';\n\nexport default defineSchema({\n // Define your tables here. Example:\n //\n // user: table({\n // id: column.serial().primaryKey(),\n // email: column.text().notNull().unique(),\n // name: column.text().nullable(),\n // createdAt: column.timestamp().default('now()').notNull(),\n // }),\n});\n";
|
|
177
|
+
/**
|
|
178
|
+
* Default config file template.
|
|
179
|
+
*/
|
|
180
|
+
declare const configTemplate = "import type { KyselySchemaConfig } from 'kysely-schema';\n\nconst config: KyselySchemaConfig = {\n schemaPath: './schema/index.ts',\n migrationsDir: './migrations',\n generatedDir: './generated',\n snapshotDir: './.kysely-schema',\n};\n\nexport default config;\n";
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Compares two schema snapshots and returns a list of diff operations
|
|
184
|
+
* needed to migrate from `previous` to `current`.
|
|
185
|
+
*/
|
|
186
|
+
declare class SchemaDiffer {
|
|
187
|
+
diff(previous: SchemaDefinition, current: SchemaDefinition): DiffOperation[];
|
|
188
|
+
/**
|
|
189
|
+
* Generate an ALTER-TABLE migration string from a list of diff operations.
|
|
190
|
+
*/
|
|
191
|
+
generateAlterMigration(ops: DiffOperation[]): {
|
|
192
|
+
up: string;
|
|
193
|
+
down: string;
|
|
194
|
+
};
|
|
195
|
+
private columnsEqual;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Labels used when printing diffs to the console.
|
|
200
|
+
*/
|
|
201
|
+
declare const operationLabels: Record<DiffOperation['type'], string>;
|
|
202
|
+
/**
|
|
203
|
+
* Return a human-readable summary for a diff operation.
|
|
204
|
+
*/
|
|
205
|
+
declare function describeOperation(op: DiffOperation): string;
|
|
206
|
+
|
|
207
|
+
export { type AddColumnOperation, type AddIndexOperation, type AddTableOperation, type AlterColumnOperation, ColumnBuilder, type ColumnDefinition, type ColumnType, type DiffOperation, type DiffOperationType, type DropColumnOperation, type DropIndexOperation, type DropTableOperation, type ForeignKeyReference, type IndexDefinition, type KyselySchemaConfig, type MigrationFile, MigrationGenerator, type ReferentialAction, type SchemaDefinition, SchemaDiffer, type SchemaSnapshot, type TableDefinition, TypeGenerator, type ValidationError, column, configTemplate, defineSchema, describeOperation, operationLabels, schemaTemplate, table, validateSchema };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
type ReferentialAction = 'cascade' | 'set null' | 'restrict' | 'no action';
|
|
2
|
+
type ColumnType = 'serial' | 'integer' | 'bigint' | 'decimal' | 'text' | 'varchar' | 'timestamp' | 'date' | 'time' | 'boolean' | 'json' | 'jsonb' | 'binary' | 'uuid';
|
|
3
|
+
interface ForeignKeyReference {
|
|
4
|
+
table: string;
|
|
5
|
+
column: string;
|
|
6
|
+
}
|
|
7
|
+
interface ColumnDefinition {
|
|
8
|
+
type: ColumnType;
|
|
9
|
+
primaryKey?: boolean;
|
|
10
|
+
notNull?: boolean;
|
|
11
|
+
nullable?: boolean;
|
|
12
|
+
unique?: boolean;
|
|
13
|
+
default?: string | number | boolean;
|
|
14
|
+
references?: ForeignKeyReference;
|
|
15
|
+
onDelete?: ReferentialAction;
|
|
16
|
+
onUpdate?: ReferentialAction;
|
|
17
|
+
index?: boolean;
|
|
18
|
+
check?: string;
|
|
19
|
+
length?: number;
|
|
20
|
+
precision?: number;
|
|
21
|
+
scale?: number;
|
|
22
|
+
}
|
|
23
|
+
interface IndexDefinition {
|
|
24
|
+
name?: string;
|
|
25
|
+
columns: string[];
|
|
26
|
+
unique?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface TableDefinition {
|
|
29
|
+
columns: Record<string, ColumnDefinition>;
|
|
30
|
+
indexes: IndexDefinition[];
|
|
31
|
+
checks?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface SchemaDefinition {
|
|
34
|
+
tables: Record<string, TableDefinition>;
|
|
35
|
+
}
|
|
36
|
+
interface MigrationFile {
|
|
37
|
+
filename: string;
|
|
38
|
+
content: string;
|
|
39
|
+
}
|
|
40
|
+
type DiffOperationType = 'addTable' | 'dropTable' | 'addColumn' | 'dropColumn' | 'alterColumn' | 'addIndex' | 'dropIndex';
|
|
41
|
+
interface BaseDiffOperation {
|
|
42
|
+
type: DiffOperationType;
|
|
43
|
+
description: string;
|
|
44
|
+
}
|
|
45
|
+
interface AddTableOperation extends BaseDiffOperation {
|
|
46
|
+
type: 'addTable';
|
|
47
|
+
tableName: string;
|
|
48
|
+
table: TableDefinition;
|
|
49
|
+
}
|
|
50
|
+
interface DropTableOperation extends BaseDiffOperation {
|
|
51
|
+
type: 'dropTable';
|
|
52
|
+
tableName: string;
|
|
53
|
+
}
|
|
54
|
+
interface AddColumnOperation extends BaseDiffOperation {
|
|
55
|
+
type: 'addColumn';
|
|
56
|
+
tableName: string;
|
|
57
|
+
columnName: string;
|
|
58
|
+
column: ColumnDefinition;
|
|
59
|
+
}
|
|
60
|
+
interface DropColumnOperation extends BaseDiffOperation {
|
|
61
|
+
type: 'dropColumn';
|
|
62
|
+
tableName: string;
|
|
63
|
+
columnName: string;
|
|
64
|
+
}
|
|
65
|
+
interface AlterColumnOperation extends BaseDiffOperation {
|
|
66
|
+
type: 'alterColumn';
|
|
67
|
+
tableName: string;
|
|
68
|
+
columnName: string;
|
|
69
|
+
oldColumn: ColumnDefinition;
|
|
70
|
+
newColumn: ColumnDefinition;
|
|
71
|
+
}
|
|
72
|
+
interface AddIndexOperation extends BaseDiffOperation {
|
|
73
|
+
type: 'addIndex';
|
|
74
|
+
tableName: string;
|
|
75
|
+
index: IndexDefinition;
|
|
76
|
+
}
|
|
77
|
+
interface DropIndexOperation extends BaseDiffOperation {
|
|
78
|
+
type: 'dropIndex';
|
|
79
|
+
tableName: string;
|
|
80
|
+
indexName: string;
|
|
81
|
+
}
|
|
82
|
+
type DiffOperation = AddTableOperation | DropTableOperation | AddColumnOperation | DropColumnOperation | AlterColumnOperation | AddIndexOperation | DropIndexOperation;
|
|
83
|
+
interface SchemaSnapshot {
|
|
84
|
+
version: string;
|
|
85
|
+
timestamp: string;
|
|
86
|
+
schema: SchemaDefinition;
|
|
87
|
+
}
|
|
88
|
+
interface KyselySchemaConfig {
|
|
89
|
+
schemaPath: string;
|
|
90
|
+
migrationsDir: string;
|
|
91
|
+
generatedDir: string;
|
|
92
|
+
snapshotDir: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare class ColumnBuilder {
|
|
96
|
+
private def;
|
|
97
|
+
constructor(init: Partial<ColumnDefinition> & {
|
|
98
|
+
type: ColumnType;
|
|
99
|
+
});
|
|
100
|
+
primaryKey(): this;
|
|
101
|
+
notNull(): this;
|
|
102
|
+
nullable(): this;
|
|
103
|
+
unique(): this;
|
|
104
|
+
default(value: string | number | boolean): this;
|
|
105
|
+
references(table: string, col: string): this;
|
|
106
|
+
onDelete(action: ReferentialAction): this;
|
|
107
|
+
onUpdate(action: ReferentialAction): this;
|
|
108
|
+
index(): this;
|
|
109
|
+
check(expression: string): this;
|
|
110
|
+
/** @internal Return the raw column definition. */
|
|
111
|
+
build(): ColumnDefinition;
|
|
112
|
+
}
|
|
113
|
+
declare const column: {
|
|
114
|
+
serial: () => ColumnBuilder;
|
|
115
|
+
integer: () => ColumnBuilder;
|
|
116
|
+
bigint: () => ColumnBuilder;
|
|
117
|
+
decimal: (precision?: number, scale?: number) => ColumnBuilder;
|
|
118
|
+
text: () => ColumnBuilder;
|
|
119
|
+
varchar: (length?: number) => ColumnBuilder;
|
|
120
|
+
timestamp: () => ColumnBuilder;
|
|
121
|
+
date: () => ColumnBuilder;
|
|
122
|
+
time: () => ColumnBuilder;
|
|
123
|
+
boolean: () => ColumnBuilder;
|
|
124
|
+
json: () => ColumnBuilder;
|
|
125
|
+
jsonb: () => ColumnBuilder;
|
|
126
|
+
binary: () => ColumnBuilder;
|
|
127
|
+
uuid: () => ColumnBuilder;
|
|
128
|
+
};
|
|
129
|
+
declare function table(columns: Record<string, ColumnBuilder>): TableDefinition;
|
|
130
|
+
declare function defineSchema(tables: Record<string, TableDefinition>): SchemaDefinition;
|
|
131
|
+
|
|
132
|
+
interface ValidationError {
|
|
133
|
+
table: string;
|
|
134
|
+
column?: string;
|
|
135
|
+
message: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Validate a schema definition and return a list of problems.
|
|
139
|
+
* Returns an empty array if the schema is valid.
|
|
140
|
+
*/
|
|
141
|
+
declare function validateSchema(schema: SchemaDefinition): ValidationError[];
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Generates Kysely migration files from a SchemaDefinition.
|
|
145
|
+
*/
|
|
146
|
+
declare class MigrationGenerator {
|
|
147
|
+
/**
|
|
148
|
+
* Generate a full CREATE-TABLE migration for the entire schema.
|
|
149
|
+
*/
|
|
150
|
+
generate(schema: SchemaDefinition, migrationName: string): MigrationFile;
|
|
151
|
+
private generateUpFunction;
|
|
152
|
+
private generateCreateTable;
|
|
153
|
+
private generateColumnDefinition;
|
|
154
|
+
private buildModifiers;
|
|
155
|
+
private generateDownFunction;
|
|
156
|
+
private generateIndexes;
|
|
157
|
+
private mapColumnType;
|
|
158
|
+
private formatDefaultValue;
|
|
159
|
+
private generateTimestamp;
|
|
160
|
+
private sanitize;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Generates a TypeScript `Database` interface from a SchemaDefinition.
|
|
165
|
+
*/
|
|
166
|
+
declare class TypeGenerator {
|
|
167
|
+
generate(schema: SchemaDefinition): string;
|
|
168
|
+
private mapToTypeScript;
|
|
169
|
+
private baseTypeMap;
|
|
170
|
+
private toPascalCase;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Default schema template written by `kysely-schema init`.
|
|
175
|
+
*/
|
|
176
|
+
declare const schemaTemplate = "import { defineSchema, table, column } from 'kysely-schema';\n\nexport default defineSchema({\n // Define your tables here. Example:\n //\n // user: table({\n // id: column.serial().primaryKey(),\n // email: column.text().notNull().unique(),\n // name: column.text().nullable(),\n // createdAt: column.timestamp().default('now()').notNull(),\n // }),\n});\n";
|
|
177
|
+
/**
|
|
178
|
+
* Default config file template.
|
|
179
|
+
*/
|
|
180
|
+
declare const configTemplate = "import type { KyselySchemaConfig } from 'kysely-schema';\n\nconst config: KyselySchemaConfig = {\n schemaPath: './schema/index.ts',\n migrationsDir: './migrations',\n generatedDir: './generated',\n snapshotDir: './.kysely-schema',\n};\n\nexport default config;\n";
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Compares two schema snapshots and returns a list of diff operations
|
|
184
|
+
* needed to migrate from `previous` to `current`.
|
|
185
|
+
*/
|
|
186
|
+
declare class SchemaDiffer {
|
|
187
|
+
diff(previous: SchemaDefinition, current: SchemaDefinition): DiffOperation[];
|
|
188
|
+
/**
|
|
189
|
+
* Generate an ALTER-TABLE migration string from a list of diff operations.
|
|
190
|
+
*/
|
|
191
|
+
generateAlterMigration(ops: DiffOperation[]): {
|
|
192
|
+
up: string;
|
|
193
|
+
down: string;
|
|
194
|
+
};
|
|
195
|
+
private columnsEqual;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Labels used when printing diffs to the console.
|
|
200
|
+
*/
|
|
201
|
+
declare const operationLabels: Record<DiffOperation['type'], string>;
|
|
202
|
+
/**
|
|
203
|
+
* Return a human-readable summary for a diff operation.
|
|
204
|
+
*/
|
|
205
|
+
declare function describeOperation(op: DiffOperation): string;
|
|
206
|
+
|
|
207
|
+
export { type AddColumnOperation, type AddIndexOperation, type AddTableOperation, type AlterColumnOperation, ColumnBuilder, type ColumnDefinition, type ColumnType, type DiffOperation, type DiffOperationType, type DropColumnOperation, type DropIndexOperation, type DropTableOperation, type ForeignKeyReference, type IndexDefinition, type KyselySchemaConfig, type MigrationFile, MigrationGenerator, type ReferentialAction, type SchemaDefinition, SchemaDiffer, type SchemaSnapshot, type TableDefinition, TypeGenerator, type ValidationError, column, configTemplate, defineSchema, describeOperation, operationLabels, schemaTemplate, table, validateSchema };
|