Skip to content

Commit

Permalink
Added example for 'existingDatabaseSchema'
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Oct 7, 2024
1 parent 3f1a086 commit eed016c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion beam-migrate/Database/Beam/Migrate/SQL/Tables.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,18 @@ dropDatabaseSchema :: BeamMigrateSchemaSqlBackend be
dropDatabaseSchema (MkDatabaseSchema nm)
= upDown (dropSchemaCmd (dropSchemaSyntax (schemaName nm))) Nothing

-- | Materialize a schema for use during a migration (for example, to drop it).
-- | Materialize a schema for use during a migration.
--
-- Example usage, where @NewDB@ has one more table than @OldDB@ in the @my_schema@ schema:
--
-- @
-- migrationStep :: 'CheckedDatabaseSettings' be OldDB
-- -> 'Migration' be ('CheckedDatabaseSettings' be NewDB)
-- migrationStep (OldDB oldtable)= do
-- schema <- 'existingDatabaseSchema' "my_schema"
-- pure $ NewDb <$> pure oldtable
-- <*> 'createTableWithSchema' (Just schema) "my_table"
-- @
existingDatabaseSchema :: Text -> Migration be DatabaseSchema
existingDatabaseSchema = pure . MkDatabaseSchema

Expand Down

0 comments on commit eed016c

Please sign in to comment.