Skip to content

Commit dac674b

Browse files
zachdanielken-kost
andauthored
feat: --dev flag for codegen (#555)
--------- Co-authored-by: ken-kost <[email protected]>
1 parent d18f6c6 commit dac674b

20 files changed

+1091
-149
lines changed

config/config.exs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ if Mix.env() == :test do
3737
hostname: "localhost",
3838
pool: Ecto.Adapters.SQL.Sandbox
3939

40+
config :ash_postgres, AshPostgres.DevTestRepo,
41+
username: "postgres",
42+
password: "postgres",
43+
database: "ash_postgres_dev_test",
44+
hostname: "localhost",
45+
migration_primary_key: [name: :id, type: :binary_id],
46+
pool: Ecto.Adapters.SQL.Sandbox
47+
4048
# sobelow_skip ["Config.Secrets"]
4149
config :ash_postgres, AshPostgres.TestRepo, password: "postgres"
4250

@@ -54,7 +62,7 @@ if Mix.env() == :test do
5462
migration_primary_key: [name: :id, type: :binary_id]
5563

5664
config :ash_postgres,
57-
ecto_repos: [AshPostgres.TestRepo, AshPostgres.TestNoSandboxRepo],
65+
ecto_repos: [AshPostgres.TestRepo, AshPostgres.DevTestRepo, AshPostgres.TestNoSandboxRepo],
5866
ash_domains: [
5967
AshPostgres.Test.Domain,
6068
AshPostgres.MultitenancyTest.Domain,

documentation/topics/development/migrations-and-tasks.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ Ash comes with its own tasks, and AshPostgres exposes lower level tasks that you
77
## Basic Workflow
88

99
- Make resource changes
10-
- Run `mix ash.codegen --name add_a_combobulator` to generate migrations and resource snapshots
10+
- Run `mix ash.codegen --dev` to generate a migration tagged as a `dev` migration, which will later be squashed and does not require a name.
11+
- Run `mix ash.migrate` to run the migrations.
12+
- Make some more resource changes.
13+
- Once you're all done, run `mix ash.codegen add_a_combobulator`, using a good name for your changes to generate migrations and resource snapshots. This will **rollback** the dev migrations, and squash them into a the new named migration (or sometimes migrations).
1114
- Run `mix ash.migrate` to run those migrations
1215

16+
The `--dev` workflow enables you to avoid having to think of a name for migrations while developing, and also enables some
17+
upcoming workflows that will detect when code generation needs to be run on page load and will show you a button to generate
18+
dev migrations and run them.
19+
1320
For more information on generating migrations, run `mix help ash_postgres.generate_migrations` (the underlying task that is called by `mix ash.migrate`)
1421

1522
> ### list_tenants/0 {: .info}

0 commit comments

Comments
 (0)