DEVELOPMENT ENVIRONMENT

~liljamo/felu

6dd64c0118da0250831b17bf3a44420307eba9de — Jonni Liljamo 1 year, 1 month ago ea7f665
fix: actually working unique constraints

yes, another breaking change to the initial schema
2 files changed, 7 insertions(+), 8 deletions(-)

M db/db.go
M db/migrations.go
M db/db.go => db/db.go +2 -1
@@ 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
	}

M db/migrations.go => db/migrations.go +5 -7
@@ 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)
		)`),
	}