Skip to content

Commit

Permalink
fix(sqlite): move table and index creation to single call
Browse files Browse the repository at this point in the history
  • Loading branch information
christianmat committed Jan 22, 2024
1 parent 7b5dde2 commit c8e6437
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -10,8 +10,9 @@ export class SqliteService implements OnModuleInit, DataService {
async onModuleInit() {
try {
this.db = new this.sqlite3.Database('./database.sqlite')
await this.db.run('CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, value TEXT)')
await this.db.run('CREATE INDEX IF NOT EXISTS key_index ON kv (key)')
await this.db.run(
'CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, value TEXT); CREATE INDEX IF NOT EXISTS key_index ON kv (key)'
)
} catch (e) {
console.error('Failed to initialize sqlite database', e)
}
Expand Down

0 comments on commit c8e6437

Please sign in to comment.