Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

Make sure the right columns get migrated into the correct columns

Matthew Kilgore731765c36c9e
diff --git a/backend/internal/data/migrations/sqlite3/20250907000000_make_password_nullable.sql b/backend/internal/data/migrations/sqlite3/20250907000000_make_password_nullable.sql
index 90679de5..626daf6a 100644
--- a/backend/internal/data/migrations/sqlite3/20250907000000_make_password_nullable.sql
+++ b/backend/internal/data/migrations/sqlite3/20250907000000_make_password_nullable.sql
@@ -1,5 +1,4 @@
-- +goose Up
--- +goose StatementBegin
-- 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 +20,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;
@@ -30,39 +29,4 @@ DROP TABLE users;
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
\ No newline at end of file
+CREATE UNIQUE INDEX users_email_key on users (email);
\ No newline at end of file