diff options
| author | xengineering <me@xengineering.eu> | 2026-06-22 20:09:08 +0200 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-06-22 20:10:50 +0200 |
| commit | 56dd6588503908d9a562445c1cb6a99c2a7aa415 (patch) | |
| tree | 94cc4009ccbeaca0cfcbc2733e1ced63e78dcb33 | |
| parent | a4535e0aa3e103f87bae6c3f1a1527588e60208c (diff) | |
| download | finserv-56dd6588503908d9a562445c1cb6a99c2a7aa415.tar finserv-56dd6588503908d9a562445c1cb6a99c2a7aa415.tar.zst finserv-56dd6588503908d9a562445c1cb6a99c2a7aa415.zip | |
sql: migrations: Add 0003.sqlite3
This adds persistence for tokens.
| -rw-r--r-- | main.go | 5 | ||||
| -rw-r--r-- | sql/migrations/0003.sqlite3 | 12 |
2 files changed, 17 insertions, 0 deletions
@@ -58,6 +58,11 @@ func run( } defer db.Close() + _, err = db.Exec(`PRAGMA foreign_keys = ON;`) + if err != nil { + log.Fatalf("Failed to enable foreign key support in database: %v", err) + } + err = MigrateToLatest(db) if err != nil { log.Fatalf("Failed to migrate SQLite3 database '%s': %v", dbPath, err) diff --git a/sql/migrations/0003.sqlite3 b/sql/migrations/0003.sqlite3 new file mode 100644 index 0000000..79f7516 --- /dev/null +++ b/sql/migrations/0003.sqlite3 @@ -0,0 +1,12 @@ +PRAGMA user_version = 3; + +CREATE TABLE tokens ( + id INTEGER PRIMARY KEY, + user_id INTEGER NOT NULL, + token TEXT NOT NULL, + created_at DATETIME NOT NULL DEFAULT (datetime('now')), + + FOREIGN KEY (user_id) REFERENCES users(id) + ON DELETE CASCADE + ON UPDATE CASCADE +); |
