@@ 17,7 17,8 @@ var DBConn *sql.DB
func InitDB() error {
var err error
- DBConn, err = sql.Open("sqlite3", config.FeluConfig.DataDir + "felu.db")
+ DBConn, err = sql.Open("sqlite3",
+ config.FeluConfig.DataDir + "felu.db?_foreign_keys=true")
if err != nil {
return err
}
@@ 66,19 66,17 @@ func migrations() []string {
schema_version INTEGER
)`, migrationsTable),
fmt.Sprintf(`CREATE TABLE users (
- id TEXT NOT NULL PRIMARY KEY,
- email TEXT NOT NULL,
+ id TEXT NOT NULL PRIMARY KEY UNIQUE,
+ email TEXT NOT NULL UNIQUE,
pwd TEXT NOT NULL,
- is_admin INTEGER DEFAULT FALSE NOT NULL,
- UNIQUE(id, email)
+ is_admin INTEGER DEFAULT FALSE NOT NULL
)`),
fmt.Sprintf(`CREATE TABLE domains (
- id TEXT NOT NULL PRIMARY KEY,
+ id TEXT NOT NULL PRIMARY KEY UNIQUE,
apikey TEXT NOT NULL,
owner TEXT NOT NULL,
- ddns_domain TEXT NOT NULL,
+ ddns_domain TEXT NOT NULL UNIQUE,
a_record TEXT,
- UNIQUE(id, ddns_domain),
FOREIGN KEY(owner) REFERENCES users(id)
)`),
}