diff --git a/migrations/2024-04-29-012112_forbid_diesel_cli/down.sql b/migrations/2024-04-29-012112_forbid_diesel_cli/down.sql deleted file mode 100644 index d6e8132be..000000000 --- a/migrations/2024-04-29-012112_forbid_diesel_cli/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP FUNCTION forbid_diesel_cli CASCADE; - diff --git a/migrations/2024-04-29-012112_forbid_diesel_cli/up.sql b/migrations/2024-04-29-012112_forbid_diesel_cli/up.sql deleted file mode 100644 index a2f839156..000000000 --- a/migrations/2024-04-29-012112_forbid_diesel_cli/up.sql +++ /dev/null @@ -1,33 +0,0 @@ --- This trigger prevents using the Diesel CLI to run or revert migrations, so the custom migration runner --- can drop and recreate the `r` schema for new migrations. --- --- This migration being seperate from the next migration (created in the same PR) guarantees that the --- Diesel CLI will fail to bring the number of pending migrations to 0, which is one of the conditions --- required to skip running replaceable_schema. --- --- If the Diesel CLI could run or revert migrations, this scenario would be possible: --- --- Run `diesel migration redo` when the newest migration has a new table with triggers. End up with triggers --- being dropped and not replaced because triggers are created outside of up.sql. The custom migration runner --- sees that there are no pending migrations and the value in the `previously_run_sql` trigger is correct, so --- it doesn't rebuild the `r` schema. There is now incorrect behavior but no error messages. -CREATE FUNCTION forbid_diesel_cli () - RETURNS TRIGGER - LANGUAGE plpgsql - AS $$ -BEGIN - IF NOT EXISTS ( - SELECT - FROM - pg_locks - WHERE (locktype, pid, objid) = ('advisory', pg_backend_pid(), 0)) THEN -RAISE 'migrations must be managed using lemmy_server instead of diesel CLI'; -END IF; - RETURN NULL; -END; -$$; - -CREATE TRIGGER forbid_diesel_cli - BEFORE INSERT OR UPDATE OR DELETE OR TRUNCATE ON __diesel_schema_migrations - EXECUTE FUNCTION forbid_diesel_cli (); - diff --git a/migrations/2024-04-29-012113_custom_migration_runner/down.sql b/migrations/2024-04-29-012113_custom_migration_runner/down.sql deleted file mode 100644 index 6ea5a2e22..000000000 --- a/migrations/2024-04-29-012113_custom_migration_runner/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP TABLE previously_run_sql; - diff --git a/migrations/2024-04-29-012113_custom_migration_runner/up.sql b/migrations/2024-04-29-012113_custom_migration_runner/up.sql deleted file mode 100644 index 61985c2cf..000000000 --- a/migrations/2024-04-29-012113_custom_migration_runner/up.sql +++ /dev/null @@ -1,12 +0,0 @@ -DROP SCHEMA IF EXISTS r CASCADE; - -CREATE TABLE previously_run_sql ( - -- For compatibility with Diesel - id boolean PRIMARY KEY, - -- Too big to be used as primary key - content text NOT NULL -); - -INSERT INTO previously_run_sql (id, content) - VALUES (TRUE, ''); -