Compare commits

...

3 Commits

Author SHA1 Message Date
Matthew Kilgore
473027c1ae Fix notifiers gettings wiped 2025-12-26 17:27:18 -05:00
Matthew Kilgore
3a77440996 Fix flip flopped columns 2025-12-26 15:50:04 -05:00
Matthew Kilgore
731765c36c Make sure the right columns get migrated into the correct columns 2025-12-26 15:09:02 -05:00
2 changed files with 8 additions and 37 deletions

View File

@@ -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;

View File

@@ -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;