aboutsummaryrefslogtreecommitdiff
path: root/pkg/database/migrations.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-04-10 20:11:35 +0200
committerJulien Dessaux2021-04-12 11:11:38 +0200
commitb7c3e058e9b161065b9024458fc7be0b3c5e8cb5 (patch)
treed8a5d047f2aaabb7118a86123cd61761aa4bda6a /pkg/database/migrations.go
parentBegan implementing a database backend (diff)
downloadtrains-b7c3e058e9b161065b9024458fc7be0b3c5e8cb5.tar.gz
trains-b7c3e058e9b161065b9024458fc7be0b3c5e8cb5.tar.bz2
trains-b7c3e058e9b161065b9024458fc7be0b3c5e8cb5.zip
Implemented a user table and the CreateUser function
Diffstat (limited to 'pkg/database/migrations.go')
-rw-r--r--pkg/database/migrations.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/database/migrations.go b/pkg/database/migrations.go
index cec3c41..8d23ed2 100644
--- a/pkg/database/migrations.go
+++ b/pkg/database/migrations.go
@@ -9,6 +9,14 @@ var allMigrations = []func(tx *sql.Tx) error{
sql := `
CREATE TABLE schema_version (
version INTEGER NOT NULL
+ );
+ CREATE TABLE users (
+ id INTEGER PRIMARY KEY,
+ username TEXT NOT NULL UNIQUE,
+ password TEXT,
+ email TEXT,
+ created_at DATE DEFAULT (datetime('now')),
+ last_login_at DATE DEFAULT NULL
);`
_, err = tx.Exec(sql)
return err