mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-27 15:41:42 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
473027c1ae | ||
|
|
3a77440996 | ||
|
|
731765c36c |
@@ -1,5 +1,6 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
-- +goose no transaction
|
||||
PRAGMA foreign_keys=OFF;
|
||||
-- SQLite doesn't support ALTER COLUMN directly, so we need to recreate the table
|
||||
-- Create a temporary table with the new schema
|
||||
CREATE TABLE users_temp (
|
||||
@@ -21,7 +22,7 @@ CREATE TABLE users_temp (
|
||||
);
|
||||
|
||||
-- Copy data from the original table
|
||||
INSERT INTO users_temp SELECT * FROM users;
|
||||
INSERT INTO users_temp SELECT id, created_at, updated_at, name, email, password, is_superuser, superuser, role, activated_on, group_users FROM users;
|
||||
|
||||
-- Drop the original table
|
||||
DROP TABLE users;
|
||||
@@ -31,38 +32,4 @@ ALTER TABLE users_temp RENAME TO users;
|
||||
|
||||
-- Recreate the unique index
|
||||
CREATE UNIQUE INDEX users_email_key on users (email);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
-- Create the original table structure
|
||||
CREATE TABLE users_temp (
|
||||
id uuid not null
|
||||
primary key,
|
||||
created_at datetime not null,
|
||||
updated_at datetime not null,
|
||||
name text not null,
|
||||
email text not null,
|
||||
password text not null,
|
||||
is_superuser bool default false not null,
|
||||
superuser bool default false not null,
|
||||
role text default 'user' not null,
|
||||
activated_on datetime,
|
||||
group_users uuid not null
|
||||
constraint users_groups_users
|
||||
references groups
|
||||
on delete cascade
|
||||
);
|
||||
|
||||
-- Copy data from the current table (this will fail if there are NULL passwords)
|
||||
INSERT INTO users_temp SELECT * FROM users;
|
||||
|
||||
-- Drop the current table
|
||||
DROP TABLE users;
|
||||
|
||||
-- Rename the temporary table
|
||||
ALTER TABLE users_temp RENAME TO users;
|
||||
|
||||
-- Recreate the unique index
|
||||
CREATE UNIQUE INDEX users_email_key on users (email);
|
||||
-- +goose StatementEnd
|
||||
PRAGMA foreign_keys=ON;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- +goose Up
|
||||
-- Force the role and superuser flags, previous nullable password migration (prior to v0.22.2)
|
||||
-- caused them to flip-flop during migration for some users.
|
||||
UPDATE users SET role = 'owner', is_superuser = 0, superuser = 0;
|
||||
Reference in New Issue
Block a user