bun-query-builder 0.1.2 → 0.1.5

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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Run performance benchmarks
3
+ */
4
+ export declare function runBenchmark(options?: BenchmarkOptions): Promise<void>;
5
+ export declare interface BenchmarkOptions {
6
+ operations?: string
7
+ iterations?: number
8
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Clear the query cache
3
+ */
4
+ export declare function cacheClear(): Promise<void>;
5
+ /**
6
+ * Show cache statistics and configuration
7
+ *
8
+ * Note: The current cache implementation doesn't track detailed statistics.
9
+ * This command shows the current configuration.
10
+ */
11
+ export declare function cacheStats(): Promise<void>;
12
+ /**
13
+ * Configure query cache settings
14
+ */
15
+ export declare function cacheConfig(options?: CacheConfigOptions): Promise<void>;
16
+ export declare interface CacheConfigOptions {
17
+ size?: number
18
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Start an interactive REPL for running queries
3
+ */
4
+ export declare function startConsole(): Promise<void>;
5
+ /**
6
+ * Tinker - alias for startConsole
7
+ */
8
+ export declare function tinker(): Promise<void>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Export data from a table
3
+ */
4
+ export declare function exportData(tableName: string, options?: ExportOptions): Promise<void>;
5
+ /**
6
+ * Import data into a table
7
+ */
8
+ export declare function importData(tableName: string, filePath: string, options?: ImportOptions): Promise<void>;
9
+ /**
10
+ * Dump database or specific tables to SQL
11
+ */
12
+ export declare function dumpDatabase(options?: DumpOptions): Promise<void>;
13
+ export declare interface ExportOptions {
14
+ format?: 'json' | 'csv' | 'sql'
15
+ output?: string
16
+ limit?: number
17
+ }
18
+ export declare interface ImportOptions {
19
+ format?: 'json' | 'csv'
20
+ truncate?: boolean
21
+ }
22
+ export declare interface DumpOptions {
23
+ tables?: string
24
+ output?: string
25
+ }
@@ -0,0 +1,22 @@
1
+ import type { SupportedDialect } from '@/types';
2
+ /**
3
+ * Get database information and statistics
4
+ */
5
+ export declare function dbInfo(): Promise<DatabaseInfo>;
6
+ /**
7
+ * Get database statistics (alias for dbInfo)
8
+ */
9
+ export declare function dbStats(): Promise<DatabaseInfo>;
10
+ export declare interface TableInfo {
11
+ name: string
12
+ rowCount: number
13
+ columns?: number
14
+ indexes?: number
15
+ }
16
+ export declare interface DatabaseInfo {
17
+ dialect: SupportedDialect
18
+ database: string
19
+ tables: TableInfo[]
20
+ totalTables: number
21
+ totalRows: number
22
+ }
@@ -0,0 +1,12 @@
1
+ import type { SupportedDialect } from '@/types';
2
+ /**
3
+ * Optimize database tables (VACUUM, ANALYZE, OPTIMIZE)
4
+ */
5
+ export declare function dbOptimize(options?: OptimizeOptions): Promise<void>;
6
+ export declare interface OptimizeOptions {
7
+ dialect?: SupportedDialect
8
+ aggressive?: boolean
9
+ tables?: string[]
10
+ verbose?: boolean
11
+ }
12
+ export { dbOptimize as optimizeDatabase };
@@ -0,0 +1,11 @@
1
+ import type { SupportedDialect } from '@/types';
2
+ /**
3
+ * Drop all tables in the database
4
+ */
5
+ export declare function dbWipe(options?: WipeOptions): Promise<void>;
6
+ export declare interface WipeOptions {
7
+ dialect?: SupportedDialect
8
+ force?: boolean
9
+ verbose?: boolean
10
+ }
11
+ export { dbWipe as wipeDatabase };
@@ -1,8 +1,25 @@
1
+ export { runBenchmark } from './benchmark';
2
+ export { cacheClear, cacheConfig, cacheStats } from './cache';
3
+ export { startConsole, tinker } from './console';
4
+ export { dumpDatabase, exportData, importData } from './data';
5
+ export { dbInfo, dbStats } from './db-info';
6
+ export { dbOptimize, optimizeDatabase } from './db-optimize';
7
+ export { dbWipe, wipeDatabase } from './db-wipe';
1
8
  export { explain } from './explain';
2
9
  export { file } from './file';
10
+ export { inspectTable, tableInfo } from './inspect';
3
11
  export { introspect } from './introspect';
4
- export { executeMigration, generateMigration } from './migrate';
12
+ export { makeModel } from './make-model';
13
+ export { executeMigration, generateMigration, resetDatabase } from './migrate';
14
+ export { migrateGenerate } from './migrate-generate';
15
+ export { migrateRollback } from './migrate-rollback';
16
+ export { migrateList, migrateStatus } from './migrate-status';
17
+ export { modelShow, showModel } from './model-show';
5
18
  export { ping } from './ping';
19
+ export { explainAllQueries, queryExplainAll } from './query-explain-all';
20
+ export { generateDiagram, relationDiagram } from './relation-diagram';
21
+ export { freshDatabase, makeSeeder, runSeeder, runSeeders } from './seed';
6
22
  export { sql } from './sql';
7
23
  export { unsafe } from './unsafe';
24
+ export { checkSchema, validateSchema } from './validate';
8
25
  export { waitReady } from './wait-ready';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Inspect a table's structure, indexes, and statistics
3
+ */
4
+ export declare function inspectTable(tableName: string, options?: InspectOptions): Promise<TableInspection>;
5
+ /**
6
+ * Alias for inspectTable
7
+ */
8
+ export declare function tableInfo(tableName: string, options?: InspectOptions): Promise<TableInspection>;
9
+ export declare interface ColumnInfo {
10
+ name: string
11
+ type: string
12
+ nullable: boolean
13
+ default: any
14
+ isPrimaryKey?: boolean
15
+ isForeignKey?: boolean
16
+ }
17
+ export declare interface IndexInfo {
18
+ name: string
19
+ columns: string[]
20
+ unique: boolean
21
+ }
22
+ export declare interface TableInspection {
23
+ tableName: string
24
+ rowCount: number
25
+ columns: ColumnInfo[]
26
+ indexes: IndexInfo[]
27
+ }
28
+ export declare interface InspectOptions {
29
+ verbose?: boolean
30
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generate a new model file
3
+ */
4
+ export declare function makeModel(name: string, options?: MakeModelOptions): Promise<void>;
5
+ export declare interface MakeModelOptions {
6
+ table?: string
7
+ dir?: string
8
+ timestamps?: boolean
9
+ }
@@ -0,0 +1,6 @@
1
+ import type { GenerateMigrationResult, MigrateOptions } from '@/types';
2
+ /**
3
+ * Generate migration files from model changes (alias for generateMigration)
4
+ */
5
+ export declare function migrateGenerate(dir?: string, opts?: MigrateOptions): Promise<GenerateMigrationResult>;
6
+ export { migrateGenerate as generateMigration };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Rollback migrations
3
+ *
4
+ * Note: This removes migration entries from the migrations table.
5
+ * Since migrations are auto-generated from models, you should:
6
+ * 1. Revert your model changes
7
+ * 2. Run rollback to remove migration records
8
+ * 3. Generate fresh migrations
9
+ */
10
+ export declare function migrateRollback(options?: RollbackOptions): Promise<void>;
11
+ export declare interface RollbackOptions {
12
+ steps?: number
13
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Get migration status - shows which migrations have been executed and which are pending
3
+ */
4
+ export declare function migrateStatus(): Promise<MigrationStatus[]>;
5
+ /**
6
+ * List all migrations (alias for status)
7
+ */
8
+ export declare function migrateList(): Promise<MigrationStatus[]>;
9
+ export declare interface MigrationStatus {
10
+ file: string
11
+ status: 'executed' | 'pending' | 'transient'
12
+ executedAt?: string
13
+ }
@@ -1,3 +1,21 @@
1
- import type { GenerateMigrationResult, MigrateOptions } from '../types';
2
- export declare function generateMigration(dir: string, opts?: MigrateOptions): Promise<GenerateMigrationResult>;
3
- export declare function executeMigration(migration: GenerateMigrationResult): Promise<boolean>;
1
+ import type { GenerateMigrationResult, MigrateOptions } from '@/types';
2
+ /**
3
+ * Generate migration files by comparing old models (from generated/) with new models (from source).
4
+ *
5
+ * Workflow:
6
+ * 1. Loads previous model state from the 'generated/' directory (old model copies)
7
+ * 2. Loads current models from the source directory
8
+ * 3. Compares both to detect all changes:
9
+ * - Dropped tables, columns, indexes
10
+ * - New tables, columns, indexes
11
+ * - Modified columns (type changes, etc.)
12
+ * 4. Generates SQL migration files for all detected changes
13
+ * 5. Copies current models to 'generated/' for next comparison
14
+ *
15
+ * This follows Laravel's migration philosophy where model changes drive schema changes.
16
+ */
17
+ export declare function generateMigration(dir?: string, opts?: MigrateOptions): Promise<GenerateMigrationResult>;
18
+ export declare function executeMigration(): Promise<boolean>;
19
+ export declare function resetDatabase(dir?: string, opts?: MigrateOptions): Promise<boolean>;
20
+ export declare function deleteMigrationFiles(dir?: string, workspaceRoot?: string, opts?: MigrateOptions): Promise<void>;
21
+ export declare function copyModelsToGenerated(dir?: string, workspaceRoot?: string): Promise<void>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Show detailed information about a specific model
3
+ */
4
+ export declare function modelShow(modelName: string, options?: ModelShowOptions): Promise<ModelDetails | void>;
5
+ export declare interface ModelShowOptions {
6
+ dir?: string
7
+ verbose?: boolean
8
+ json?: boolean
9
+ }
10
+ export declare interface ModelDetails {
11
+ name: string
12
+ table: string
13
+ primaryKey: string
14
+ attributes: Record<string, any>
15
+ relations?: Record<string, any>
16
+ scopes?: Record<string, any>
17
+ hooks?: string[]
18
+ indexes?: any[]
19
+ timestamps?: boolean
20
+ softDeletes?: boolean
21
+ }
22
+ export { modelShow as showModel };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Run EXPLAIN on all SQL files in a directory
3
+ */
4
+ export declare function queryExplainAll(path: string, options?: ExplainAllOptions): Promise<ExplainResult[]>;
5
+ export declare interface ExplainAllOptions {
6
+ verbose?: boolean
7
+ json?: boolean
8
+ format?: 'text' | 'json'
9
+ }
10
+ export declare interface ExplainResult {
11
+ file: string
12
+ query: string
13
+ plan: any[]
14
+ error?: string
15
+ }
16
+ export { queryExplainAll as explainAllQueries };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Generate relationship diagram from models
3
+ */
4
+ export declare function relationDiagram(options?: DiagramOptions): Promise<string>;
5
+ export declare interface DiagramOptions {
6
+ dir?: string
7
+ format?: 'mermaid' | 'dot'
8
+ output?: string
9
+ verbose?: boolean
10
+ }
11
+ export { relationDiagram as generateDiagram };
@@ -0,0 +1,18 @@
1
+ import type { RunSeederOptions, SeederConfig } from '@/seeder';
2
+ /**
3
+ * Run all seeders from a directory
4
+ */
5
+ export declare function runSeeders(config?: SeederConfig): Promise<void>;
6
+ /**
7
+ * Run a specific seeder by class name
8
+ */
9
+ export declare function runSeeder(className: string, options?: RunSeederOptions): Promise<void>;
10
+ /**
11
+ * Generate a new seeder file
12
+ */
13
+ export declare function makeSeeder(name: string): Promise<void>;
14
+ /**
15
+ * Refresh database and run all seeders
16
+ * This will drop all tables and re-run migrations and seeders
17
+ */
18
+ export declare function freshDatabase(options?: { seedersDir?: string, modelsDir?: string, verbose?: boolean }): Promise<void>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Validate that models match the database schema
3
+ */
4
+ export declare function validateSchema(dir?: string): Promise<ValidationResult>;
5
+ /**
6
+ * Check schema (alias for validateSchema)
7
+ */
8
+ export declare function checkSchema(dir?: string): Promise<ValidationResult>;
9
+ export declare interface ValidationIssue {
10
+ type: 'missing_table' | 'extra_table' | 'missing_column' | 'extra_column' | 'type_mismatch'
11
+ severity: 'error' | 'warning'
12
+ table?: string
13
+ column?: string
14
+ expected?: string
15
+ actual?: string
16
+ message: string
17
+ }
18
+ export declare interface ValidationResult {
19
+ valid: boolean
20
+ issues: ValidationIssue[]
21
+ }
package/dist/client.d.ts CHANGED
@@ -2,6 +2,28 @@ import { config } from './config';
2
2
  import type { DatabaseSchema } from './schema';
3
3
  import type { SchemaMeta } from './meta';
4
4
  export declare function createQueryBuilder<DB extends DatabaseSchema<any>>(state?: Partial<InternalState>): QueryBuilder<DB>;
5
+ /**
6
+ * # `clearQueryCache()`
7
+ *
8
+ * Clears all cached query results.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * clearQueryCache()
13
+ * ```
14
+ */
15
+ export declare function clearQueryCache(): void;
16
+ /**
17
+ * # `setQueryCacheMaxSize(size)`
18
+ *
19
+ * Sets the maximum number of cached queries (default 100).
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * setQueryCacheMaxSize(500)
24
+ * ```
25
+ */
26
+ export declare function setQueryCacheMaxSize(size: number): void;
5
27
  export declare interface WhereRaw {
6
28
  raw: any
7
29
  }
@@ -80,6 +102,7 @@ export declare interface BaseSelectQueryBuilder<DB extends DatabaseSchema<any>,
80
102
  having: (expr: WhereExpression<any>) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
81
103
  havingRaw: (fragment: any) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
82
104
  addSelect: (...columns: (keyof DB[TTable]['columns'] & string | string)[]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
105
+ select?: (columns: (keyof DB[TTable]['columns'] & string | string)[]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
83
106
  selectAll?: () => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
84
107
  orderByRaw: (fragment: any) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
85
108
  union: (other: { toSQL: () => any }) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
@@ -94,6 +117,8 @@ export declare interface BaseSelectQueryBuilder<DB extends DatabaseSchema<any>,
94
117
  whereJsonDoesntContainKey?: (path: string) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
95
118
  whereJsonLength?: (path: string, opOrLen: WhereOperator | number, len?: number) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
96
119
  with?: (...relations: string[]) => SelectQueryBuilder<DB, TTable, TSelected, any>
120
+ withPivot?: (relation: string, ...columns: string[]) => SelectQueryBuilder<DB, TTable, TSelected, any>
121
+ applyPivotColumns?: () => SelectQueryBuilder<DB, TTable, TSelected, any>
97
122
  lockForUpdate: () => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
98
123
  sharedLock: () => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
99
124
  withCTE: (name: string, sub: { toSQL: () => any }) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
@@ -153,6 +178,10 @@ export declare interface BaseSelectQueryBuilder<DB extends DatabaseSchema<any>,
153
178
  lazyById: () => AsyncIterable<TSelected>
154
179
  pipe: <R>(fn: (qb: SelectQueryBuilder<DB, TTable, TSelected, TJoined>) => R) => R
155
180
  count: () => Promise<number>
181
+ avg: (column: keyof DB[TTable]['columns'] & string) => Promise<number>
182
+ sum: (column: keyof DB[TTable]['columns'] & string) => Promise<number>
183
+ max: (column: keyof DB[TTable]['columns'] & string) => Promise<any>
184
+ min: (column: keyof DB[TTable]['columns'] & string) => Promise<any>
156
185
  rows: TSelected[]
157
186
  row: TSelected
158
187
  values: () => Promise<any[][]>
@@ -163,6 +192,7 @@ export declare interface BaseSelectQueryBuilder<DB extends DatabaseSchema<any>,
163
192
  onlyTrashed?: () => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
164
193
  scope?: (name: string, value?: any) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
165
194
  clone?: () => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
195
+ cache?: (ttlMs?: number) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
166
196
  rowNumber?: (alias?: string, partitionBy?: string | string[], orderBy?: [string, 'asc' | 'desc'][]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
167
197
  denseRank?: (alias?: string, partitionBy?: string | string[], orderBy?: [string, 'asc' | 'desc'][]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
168
198
  rank?: (alias?: string, partitionBy?: string | string[], orderBy?: [string, 'asc' | 'desc'][]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
@@ -188,6 +218,12 @@ export declare interface DeleteQueryBuilder<DB extends DatabaseSchema<any>, TTab
188
218
  execute: () => Promise<number>
189
219
  executeTakeFirst?: () => Promise<{ numDeletedRows?: number }>
190
220
  }
221
+ export declare interface TableQueryBuilder<DB extends DatabaseSchema<any>, TTable extends keyof DB & string> {
222
+ insert: (data: Partial<DB[TTable]['columns']> | Partial<DB[TTable]['columns']>[]) => InsertQueryBuilder<DB, TTable>
223
+ update: (values: Partial<DB[TTable]['columns']>) => UpdateQueryBuilder<DB, TTable>
224
+ delete: () => DeleteQueryBuilder<DB, TTable>
225
+ select: (...columns: (keyof DB[TTable]['columns'] & string)[]) => SelectQueryBuilder<DB, TTable, any>
226
+ }
191
227
  export declare interface QueryBuilder<DB extends DatabaseSchema<any>> {
192
228
  select: <TTable extends keyof DB & string, K extends keyof DB[TTable]['columns'] & string>(
193
229
  table: TTable,
@@ -197,6 +233,7 @@ export declare interface QueryBuilder<DB extends DatabaseSchema<any>> {
197
233
  insertInto: <TTable extends keyof DB & string>(table: TTable) => TypedInsertQueryBuilder<DB, TTable>
198
234
  updateTable: <TTable extends keyof DB & string>(table: TTable) => UpdateQueryBuilder<DB, TTable>
199
235
  deleteFrom: <TTable extends keyof DB & string>(table: TTable) => DeleteQueryBuilder<DB, TTable>
236
+ table: <TTable extends keyof DB & string>(table: TTable) => TableQueryBuilder<DB, TTable>
200
237
  selectFromSub: (sub: { toSQL: () => any }, alias: string) => SelectQueryBuilder<DB, keyof DB & string, any>
201
238
  sql: any
202
239
  raw: (strings: TemplateStringsArray, ...values: any[]) => any
@@ -237,6 +274,19 @@ export declare interface QueryBuilder<DB extends DatabaseSchema<any>> {
237
274
  table: TTable,
238
275
  rows: Partial<DB[TTable]['columns']>[],
239
276
  ) => Promise<void>
277
+ insertMany: <TTable extends keyof DB & string>(
278
+ table: TTable,
279
+ rows: Partial<DB[TTable]['columns']>[],
280
+ ) => Promise<void>
281
+ updateMany: <TTable extends keyof DB & string>(
282
+ table: TTable,
283
+ conditions: WhereExpression<DB[TTable]['columns']>,
284
+ data: Partial<DB[TTable]['columns']>,
285
+ ) => Promise<number>
286
+ deleteMany: <TTable extends keyof DB & string>(
287
+ table: TTable,
288
+ ids: any[],
289
+ ) => Promise<number>
240
290
  firstOrCreate: <TTable extends keyof DB & string>(
241
291
  table: TTable,
242
292
  match: Partial<DB[TTable]['columns']>,
@@ -284,6 +334,10 @@ export declare interface QueryBuilder<DB extends DatabaseSchema<any>> {
284
334
  ids?: (...names: string[]) => any
285
335
  advisoryLock?: (key: number | string) => Promise<void>
286
336
  tryAdvisoryLock?: (key: number | string) => Promise<boolean>
337
+ getRelationships?: (table: string) => Record<string, any>
338
+ hasRelationship?: (table: string, relationName: string) => boolean
339
+ getRelationshipType?: (table: string, relationName: string) => string | null
340
+ getRelationshipTarget?: (table: string, relationName: string) => string | null
287
341
  }
288
342
  declare interface InternalState {
289
343
  sql: any
@@ -424,4 +478,12 @@ export type TypedInsertQueryBuilder<DB extends DatabaseSchema<any>, TTable exten
424
478
  `${TSql} RETURNING ${string}`
425
479
  >
426
480
  }
427
- declare type TransactionIsolation = 'read committed' | 'repeatable read' | 'serializable'
481
+ declare type TransactionIsolation = 'read committed' | 'repeatable read' | 'serializable'
482
+ declare class QueryCache {
483
+ private cache: any;
484
+ private maxSize: any;
485
+ get(key: string): any | null;
486
+ set(key: string, data: any, ttlMs: number): void;
487
+ clear(): void;
488
+ setMaxSize(size: number): void;
489
+ }
package/dist/db.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { SQL } from 'bun';
2
+ /**
3
+ * Returns a Bun SQL instance configured for the current dialect and database settings.
4
+ * Handles connection errors gracefully by falling back to in-memory SQLite.
5
+ */
6
+ export declare function getBunSql(): SQL;
7
+ export declare function getOrCreateBunSql(forceNew?: any): SQL;
8
+ // Wrapper that catches "Connection closed" errors and retries with a fresh connection
9
+ export declare function withFreshConnection<T>(fn: (sql: SQL) => Promise<T>): Promise<T>;
10
+ export declare const bunSql: unknown;
11
+ export { SQL } from 'bun';
@@ -0,0 +1,10 @@
1
+ import { MySQLDriver } from './mysql';
2
+ import { PostgresDriver } from './postgres';
3
+ import { SQLiteDriver } from './sqlite';
4
+ import type { DialectDriver } from './postgres';
5
+ import type { SupportedDialect } from '../types';
6
+ export type { DialectDriver } from './postgres';
7
+ export declare function getDialectDriver(dialect: SupportedDialect): DialectDriver;
8
+ export { MySQLDriver } from './mysql';
9
+ export { PostgresDriver } from './postgres';
10
+ export { SQLiteDriver } from './sqlite';
@@ -0,0 +1,37 @@
1
+ import type { ColumnPlan, IndexPlan, TablePlan } from '../migrations';
2
+ export declare interface DialectDriver {
3
+ createEnumType: (enumTypeName: string, values: string[]) => string
4
+ createTable: (table: TablePlan) => string
5
+ createIndex: (tableName: string, index: IndexPlan) => string
6
+ addForeignKey: (tableName: string, columnName: string, refTable: string, refColumn: string) => string
7
+ addColumn: (tableName: string, column: ColumnPlan) => string
8
+ modifyColumn: (tableName: string, column: ColumnPlan) => string
9
+ dropTable: (tableName: string) => string
10
+ dropColumn: (tableName: string, columnName: string) => string
11
+ dropIndex: (tableName: string, indexName: string) => string
12
+ dropEnumType: (enumTypeName: string) => string
13
+ createMigrationsTable: () => string
14
+ getExecutedMigrationsQuery: () => string
15
+ recordMigrationQuery: () => string
16
+ }
17
+ export declare class MySQLDriver implements DialectDriver {
18
+ private quoteIdentifier(id: string): string;
19
+ private getColumnType(column: ColumnPlan): string;
20
+ private getPrimaryKeyType(column: ColumnPlan): string;
21
+ private getAutoIncrementClause(column: ColumnPlan): string;
22
+ private getDefaultValue(column: ColumnPlan): string;
23
+ createEnumType(_enumTypeName: string, _values: string[]): string;
24
+ createTable(table: TablePlan): string;
25
+ createIndex(tableName: string, index: IndexPlan): string;
26
+ addForeignKey(tableName: string, columnName: string, refTable: string, refColumn: string): string;
27
+ addColumn(tableName: string, column: ColumnPlan): string;
28
+ modifyColumn(tableName: string, column: ColumnPlan): string;
29
+ dropTable(tableName: string): string;
30
+ dropColumn(tableName: string, columnName: string): string;
31
+ dropIndex(tableName: string, indexName: string): string;
32
+ dropEnumType(_enumTypeName: string): string;
33
+ createMigrationsTable(): string;
34
+ getExecutedMigrationsQuery(): string;
35
+ recordMigrationQuery(): string;
36
+ private renderColumn(column: ColumnPlan): string;
37
+ }
@@ -0,0 +1,37 @@
1
+ import type { ColumnPlan, IndexPlan, TablePlan } from '../migrations';
2
+ export declare interface DialectDriver {
3
+ createEnumType: (enumTypeName: string, values: string[]) => string
4
+ createTable: (table: TablePlan) => string
5
+ createIndex: (tableName: string, index: IndexPlan) => string
6
+ addForeignKey: (tableName: string, columnName: string, refTable: string, refColumn: string) => string
7
+ addColumn: (tableName: string, column: ColumnPlan) => string
8
+ modifyColumn: (tableName: string, column: ColumnPlan) => string
9
+ dropTable: (tableName: string) => string
10
+ dropColumn: (tableName: string, columnName: string) => string
11
+ dropIndex: (tableName: string, indexName: string) => string
12
+ dropEnumType: (enumTypeName: string) => string
13
+ createMigrationsTable: () => string
14
+ getExecutedMigrationsQuery: () => string
15
+ recordMigrationQuery: () => string
16
+ }
17
+ export declare class PostgresDriver implements DialectDriver {
18
+ private quoteIdentifier(id: string): string;
19
+ private getColumnType(column: ColumnPlan): string;
20
+ private getPrimaryKeyType(column: ColumnPlan): string;
21
+ private getAutoIncrementClause(_column: ColumnPlan): string;
22
+ private getDefaultValue(column: ColumnPlan): string;
23
+ createEnumType(enumTypeName: string, values: string[]): string;
24
+ createTable(table: TablePlan): string;
25
+ createIndex(tableName: string, index: IndexPlan): string;
26
+ addForeignKey(tableName: string, columnName: string, refTable: string, refColumn: string): string;
27
+ addColumn(tableName: string, column: ColumnPlan): string;
28
+ modifyColumn(tableName: string, column: ColumnPlan): string;
29
+ dropTable(tableName: string): string;
30
+ dropColumn(tableName: string, columnName: string): string;
31
+ dropIndex(tableName: string, indexName: string): string;
32
+ dropEnumType(enumTypeName: string): string;
33
+ createMigrationsTable(): string;
34
+ getExecutedMigrationsQuery(): string;
35
+ recordMigrationQuery(): string;
36
+ private renderColumn(column: ColumnPlan): string;
37
+ }
@@ -0,0 +1,37 @@
1
+ import type { ColumnPlan, IndexPlan, TablePlan } from '../migrations';
2
+ export declare interface DialectDriver {
3
+ createEnumType: (enumTypeName: string, values: string[]) => string
4
+ createTable: (table: TablePlan) => string
5
+ createIndex: (tableName: string, index: IndexPlan) => string
6
+ addForeignKey: (tableName: string, columnName: string, refTable: string, refColumn: string) => string
7
+ addColumn: (tableName: string, column: ColumnPlan) => string
8
+ modifyColumn: (tableName: string, column: ColumnPlan) => string
9
+ dropTable: (tableName: string) => string
10
+ dropColumn: (tableName: string, columnName: string) => string
11
+ dropIndex: (tableName: string, indexName: string) => string
12
+ dropEnumType: (enumTypeName: string) => string
13
+ createMigrationsTable: () => string
14
+ getExecutedMigrationsQuery: () => string
15
+ recordMigrationQuery: () => string
16
+ }
17
+ export declare class SQLiteDriver implements DialectDriver {
18
+ private quoteIdentifier(id: string): string;
19
+ private getColumnType(column: ColumnPlan): string;
20
+ private getPrimaryKeyType(column: ColumnPlan): string;
21
+ private getAutoIncrementClause(column: ColumnPlan): string;
22
+ private getDefaultValue(column: ColumnPlan): string;
23
+ createEnumType(_enumTypeName: string, _values: string[]): string;
24
+ createTable(table: TablePlan): string;
25
+ createIndex(tableName: string, index: IndexPlan): string;
26
+ addForeignKey(tableName: string, columnName: string, refTable: string, refColumn: string): string;
27
+ addColumn(tableName: string, column: ColumnPlan): string;
28
+ modifyColumn(tableName: string, column: ColumnPlan): string;
29
+ dropTable(tableName: string): string;
30
+ dropColumn(tableName: string, columnName: string): string;
31
+ dropIndex(tableName: string, indexName: string): string;
32
+ dropEnumType(_enumTypeName: string): string;
33
+ createMigrationsTable(): string;
34
+ getExecutedMigrationsQuery(): string;
35
+ recordMigrationQuery(): string;
36
+ private renderColumn(column: ColumnPlan): string;
37
+ }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export * from './actions';
2
2
  export * from './client';
3
3
  export * from './config';
4
+ export * from './drivers';
4
5
  export * from './factory';
5
6
  export * from './loader';
6
7
  export * from './meta';
7
8
  export * from './migrations';
8
9
  export * from './schema';
10
+ export * from './seeder';
9
11
  export * from './types';