diff --git a/index.html b/index.html
index 44a9335..5e7c4ce 100644
--- a/index.html
+++ b/index.html
@@ -1,13 +1,36 @@
-
-
-
-
- Vite + TS
-
-
-
-
-
+
+
+
+
+
+ Vite + TS
+
+
+
+
+
+
+
diff --git a/src/migrate.ts b/src/migrate.ts
index 61b2fd0..4020a64 100644
--- a/src/migrate.ts
+++ b/src/migrate.ts
@@ -1,3 +1,5 @@
+import MIGRATIONS_TABLE from './migrations_table.sql?raw';
+
interface IDatabase {
exec: (query: string, params?: any[]) => Promise;
}
@@ -8,7 +10,6 @@ export interface Migration {
}
export class MigrationManager {
- private readonly table_name = 'migrations';
constructor(private database: IDatabase) { }
async migrate(migrations: Migration[]) {
@@ -27,14 +28,7 @@ export class MigrationManager {
}
private async init() {
- await this.database.exec(`CREATE TABLE IF NOT EXISTS ${this.table_name} (
- id INTEGER PRIMARY KEY AUTOINCREMENT,
- name TEXT NOT NULL,
- hash TEXT NOT NULL,
- created_at TEXT NOT NULL DEFAULT (datetime('now'))
-);
-
-CREATE INDEX IF NOT EXISTS idx_migrations_name ON ${this.table_name} (name);`);
+ await this.database.exec(MIGRATIONS_TABLE);
}
private async migrateOne(migration: Migration) {
diff --git a/src/migrations_table.sql b/src/migrations_table.sql
new file mode 100644
index 0000000..b371500
--- /dev/null
+++ b/src/migrations_table.sql
@@ -0,0 +1,8 @@
+CREATE TABLE IF NOT EXISTS migrations (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ name TEXT NOT NULL,
+ hash TEXT NOT NULL,
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
+);
+
+CREATE INDEX IF NOT EXISTS idx_migrations_name ON migrations (name);
diff --git a/tsconfig.json b/tsconfig.json
index 491a463..97c3dc1 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -18,7 +18,9 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
- "noUncheckedSideEffectImports": true
+ "noUncheckedSideEffectImports": true,
+
+ "types": ["vite/client"]
},
"include": ["src/migrate.ts"]
}