Skip to content

Commit

Permalink
Fixed migration generator suggesting IHP.PGListener's triggers in the…
Browse files Browse the repository at this point in the history
… migration
  • Loading branch information
mpscholten committed Apr 19, 2023
1 parent e0e1aa0 commit c693558
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions IHP/IDE/CodeGen/MigrationGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ removeNoise = filter \case
StatementCreateTable { unsafeGetCreateTable = CreateTable { name = "schema_migrations" } } -> False
AddConstraint { tableName = "schema_migrations" } -> False
CreateFunction { functionName } | "notify_" `Text.isPrefixOf` functionName -> False
CreateTrigger { name } | "did_update_" `Text.isPrefixOf` name -> False
StatementCreateTable { unsafeGetCreateTable = CreateTable { name = "large_pg_notifications" } } -> False
CreateIndex { tableName = "large_pg_notifications" } -> False
_ -> True
Expand Down
9 changes: 9 additions & 0 deletions Test/IDE/CodeGeneration/MigrationGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,15 @@ CREATE POLICY "Users can read and edit their own record" ON public.users USING (

diffSchemas targetSchema actualSchema `shouldBe` migration

it "should ignore did_update_.. triggers by IHP.PGListener" do
let actualSchema = sql $ cs [plain|
CREATE TRIGGER did_update_plans AFTER UPDATE ON public.plans FOR EACH ROW EXECUTE FUNCTION public.notify_did_change_plans();
|]
let targetSchema = []
let migration = []

diffSchemas targetSchema actualSchema `shouldBe` migration

sql :: Text -> [Statement]
sql code = case Megaparsec.runParser Parser.parseDDL "" code of
Left parsingFailed -> error (cs $ Megaparsec.errorBundlePretty parsingFailed)
Expand Down

0 comments on commit c693558

Please sign in to comment.