@@ -589,26 +589,23 @@ <h2 id="writing-migrations">✍️ Writing Migrations</h2>
589589< h2 id ="applying-migrations "> ▶️ Applying Migrations</ h2 >
590590< p > When the Postgres container starts with no existing data, SuperStack will
591591automatically run migrations once.</ p >
592- < p > After the first < code > docker compose up </ code > , migrations will only run if you
593- manually apply them.</ p >
592+ < p > After the first startup , migrations will only run if you manually apply
593+ them.</ p >
594594< p > To apply your migrations, run:</ p >
595595< div class ="highlight "> < pre > < span > </ span > < code > bin/postgres< span class ="w "> </ span > migrate
596596</ code > </ pre > </ div >
597597< p > This will:</ p >
598598< ol >
599599< li > Run any migration files that haven’t been applied yet (in filename order)</ li >
600- < li > Record each successfully applied file in < code > .applied_migrations</ code > </ li >
600+ < li > Record each successfully applied file in < code > .applied_migrations</ code > (this
601+ file lives in the postgres data volume)</ li >
601602</ ol >
602603< p > Already-applied scripts are skipped on subsequent runs.</ p >
603604< blockquote >
604- < p > 💡 < code > bin/postgres</ code > is short for < code > docker compose exec postgres</ code > </ p >
605+ < p > 💡 < code > bin/postgres</ code > is a small script that basically aliases < code > docker compose exec postgres</ code > </ p >
605606</ blockquote >
606- < h2 id ="transactions "> 🔁 Transactions</ h2 >
607- < p > Use < code > BEGIN;</ code > and < code > COMMIT;</ code > to wrap migration files when all included
608- statements are transactional. This ensures that all changes are applied
609- atomically.</ p >
610- < p > For example:</ p >
611- < div class ="highlight "> < span class ="filename "> postgres/migrations/03-create_table_example.sql</ span > < pre > < span > </ span > < code > < span class ="k "> begin</ span > < span class ="p "> ;</ span >
607+ < p > Here's an example migration script:</ p >
608+ < div class ="highlight "> < span class ="filename "> postgres/migrations/02-create_table_example.sql</ span > < pre > < span > </ span > < code > < span class ="k "> begin</ span > < span class ="p "> ;</ span >
612609
613610< span class ="k "> create</ span > < span class ="w "> </ span > < span class ="k "> table</ span > < span class ="w "> </ span > < span class ="n "> director</ span > < span class ="w "> </ span > < span class ="p "> (</ span >
614611< span class ="w "> </ span > < span class ="n "> id</ span > < span class ="w "> </ span > < span class ="nb "> serial</ span > < span class ="w "> </ span > < span class ="k "> primary</ span > < span class ="w "> </ span > < span class ="k "> key</ span > < span class ="p "> ,</ span >
@@ -623,13 +620,13 @@ <h2 id="transactions">🔁 Transactions</h2>
623620
624621< span class ="k "> commit</ span > < span class ="p "> ;</ span >
625622</ code > </ pre > </ div >
626- < blockquote >
627- < p > 💡 If your migration script only contains one statement, there's no need
628- to use a transaction, the statement will be auto-committed. </ p >
629- </ blockquote >
623+ < h2 id =" transactions " > 🔁 Transactions </ h2 >
624+ < p > Use < code > begin; </ code > and < code > commit; </ code > to wrap statements in a transaction. This
625+ ensures that all changes are applied atomically. Any statements outside of
626+ transactions will be auto-committed. </ p >
630627< p > Avoid wrapping non-transactional operations in a transaction — these will
631- cause errors if used inside < code > BEGIN ... COMMIT </ code > .</ p >
632- < p > Examples of non-transactional statements include:</ p >
628+ cause errors if used inside < code > begin ... commit </ code > . Examples of
629+ non-transactional statements include:</ p >
633630< div class ="highlight "> < pre > < span > </ span > < code > < span class ="k "> CREATE</ span > < span class ="w "> </ span > < span class ="n "> EXTENSION</ span >
634631< span class ="k "> DROP</ span > < span class ="w "> </ span > < span class ="n "> EXTENSION</ span >
635632< span class ="k "> VACUUM</ span >
0 commit comments