chore: add regen_migrations script and seed-database to Justfile
This commit is contained in:
parent
c4bd424163
commit
c91f65d04c
2 changed files with 24 additions and 2 deletions
7
Justfile
7
Justfile
|
|
@ -1,4 +1,4 @@
|
|||
run: install-dependencies start-database migrate-database
|
||||
run: install-dependencies start-database migrate-database seed-database
|
||||
mix phx.server
|
||||
|
||||
install-dependencies:
|
||||
|
|
@ -10,6 +10,9 @@ migrate-database:
|
|||
reset-database:
|
||||
mix ash.reset
|
||||
|
||||
seed-database:
|
||||
mix run priv/repo/seeds.exs
|
||||
|
||||
start-database:
|
||||
docker compose up -d
|
||||
|
||||
|
|
@ -29,4 +32,4 @@ test:
|
|||
mix test
|
||||
|
||||
format:
|
||||
mix format
|
||||
mix format
|
||||
|
|
|
|||
19
regen_migrations.sh
Executable file
19
regen_migrations.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Get count of untracked migrations
|
||||
N_MIGRATIONS=$(git ls-files --others priv/repo/migrations | wc -l)
|
||||
|
||||
# Rollback untracked migrations
|
||||
mix ash_postgres.rollback -n $N_MIGRATIONS
|
||||
|
||||
# Delete untracked migrations and snapshots
|
||||
git ls-files --others priv/repo/migrations | xargs rm
|
||||
git ls-files --others priv/resource_snapshots | xargs rm
|
||||
|
||||
# Regenerate migrations
|
||||
mix ash.codegen --name $1
|
||||
|
||||
# Run migrations if flag
|
||||
if echo $* | grep -e "-m" -q; then
|
||||
mix ash.migrate
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue