File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed
Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,16 @@ defmodule AshPostgres.MigrationGenerator.Phase do
1313 Enum . map_join ( operations , "\n " , fn operation -> operation . __struct__ . up ( operation ) end ) <>
1414 "\n end"
1515 else
16- opts =
16+ { pre_create , opts } =
1717 if schema do
18- ", prefix: \" #{ schema } \" "
18+ { "execute(\" CREATE SCHEMA IF NOT EXISTS #{ schema } \" )" <> "\n \n " ,
19+ ", prefix: \" #{ schema } \" " }
1920 else
20- ""
21+ { "" , "" }
2122 end
2223
23- "create table(:#{ as_atom ( table ) } , primary_key: false#{ opts } ) do\n " <>
24+ pre_create <>
25+ "create table(:#{ as_atom ( table ) } , primary_key: false#{ opts } ) do\n " <>
2426 Enum . map_join ( operations , "\n " , fn operation -> operation . __struct__ . up ( operation ) end ) <>
2527 "\n end"
2628 end
Original file line number Diff line number Diff line change @@ -243,14 +243,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
243243
244244 defdomain ( [ Post ] )
245245
246- { :ok , _ } =
247- Ecto.Adapters.SQL . query (
248- AshPostgres.TestRepo ,
249- """
250- CREATE SCHEMA IF NOT EXISTS example;
251- """
252- )
253-
254246 AshPostgres.MigrationGenerator . generate ( Domain ,
255247 snapshot_path: "test_snapshots_path" ,
256248 migration_path: "test_migration_path" ,
@@ -272,6 +264,9 @@ defmodule AshPostgres.MigrationGeneratorTest do
272264
273265 file_contents = File . read! ( file )
274266
267+ # the migration creates the schema
268+ assert file_contents =~ "execute(\" CREATE SCHEMA IF NOT EXISTS example\" )"
269+
275270 # the migration creates the table
276271 assert file_contents =~ "create table(:posts, primary_key: false, prefix: \" example\" ) do"
277272
You can’t perform that action at this time.
0 commit comments