• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rogerpadilla / nukak / #534

29 Dec 2025 08:43PM UTC coverage: 87.378% (-1.0%) from 88.4%
#534

push

web-flow
Merge pull request #73 from rogerpadilla/feat/migration-system-and-sync

feat: database migration system and entity-first synchronization engine

974 of 1267 branches covered (76.87%)

Branch coverage included in aggregate %.

190 of 236 new or added lines in 19 files covered. (80.51%)

3138 of 3439 relevant lines covered (91.25%)

252.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

53.06
/packages/migrate/src/generator/sqliteSchemaGenerator.ts
1
import type { ColumnType, FieldOptions } from 'nukak/type';
2
import { AbstractSchemaGenerator } from '../schemaGenerator.js';
5✔
3
import type { ColumnSchema } from '../type.js';
4

5
/**
6
 * SQLite-specific schema generator
7
 */
8
export class SqliteSchemaGenerator extends AbstractSchemaGenerator {
4✔
9
  protected readonly serialPrimaryKeyType = 'INTEGER PRIMARY KEY AUTOINCREMENT';
3✔
10

11
  public override mapColumnType(columnType: ColumnType, field: FieldOptions): string {
12
    // SQLite has dynamic typing, but we use type affinity
13
    switch (columnType) {
7!
14
      case 'int':
15
      case 'smallint':
16
      case 'bigint':
17
      case 'serial':
18
      case 'bigserial':
19
        return 'INTEGER';
3✔
20
      case 'float':
21
      case 'double':
22
      case 'real':
23
      case 'decimal':
24
      case 'numeric':
25
        return 'REAL';
×
26
      case 'boolean':
27
        return 'INTEGER'; // SQLite uses 0/1 for booleans
×
28
      case 'char':
29
      case 'varchar':
30
      case 'text':
31
      case 'uuid':
32
        return 'TEXT';
3✔
33
      case 'date':
34
      case 'time':
35
      case 'timestamp':
36
      case 'timestamptz':
37
        return 'TEXT'; // SQLite stores dates as TEXT or INTEGER
×
38
      case 'json':
39
      case 'jsonb':
40
        return 'TEXT'; // SQLite stores JSON as TEXT
1✔
41
      case 'blob':
42
      case 'bytea':
43
        return 'BLOB';
×
44
      case 'vector':
45
        return 'TEXT'; // Store as JSON array
×
46
      default:
47
        return 'TEXT';
×
48
    }
49
  }
50

51
  public override getBooleanType(): string {
52
    return 'INTEGER';
2✔
53
  }
54

55
  public override generateAlterColumnStatements(
56
    tableName: string,
57
    column: ColumnSchema,
58
    newDefinition: string,
59
  ): string[] {
60
    // SQLite has very limited ALTER TABLE support
61
    // Column type changes require recreating the table
62
    throw new Error(
1✔
63
      `SQLite does not support altering column '${column.name}' in table '${tableName}'. ` +
64
        'You need to recreate the table to change column types.',
65
    );
66
  }
67

68
  public override generateColumnComment(tableName: string, columnName: string, comment: string): string {
NEW
69
    return '';
×
70
  }
71

72
  override generateDropIndex(tableName: string, indexName: string): string {
73
    return `DROP INDEX IF EXISTS ${this.escapeId(indexName)};`;
×
74
  }
75

76
  override formatDefaultValue(value: unknown): string {
77
    if (typeof value === 'boolean') {
4✔
78
      return value ? '1' : '0';
2✔
79
    }
80
    return super.formatDefaultValue(value);
2✔
81
  }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc