Download the PHP package swouters/sql-migrations-bundle without Composer
On this page you can find all versions of the php package swouters/sql-migrations-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download swouters/sql-migrations-bundle
More information about swouters/sql-migrations-bundle
Files in swouters/sql-migrations-bundle
Package sql-migrations-bundle
Short Description Allow symfony database versioning using SQL plain files.
License
Informations about the package sql-migrations-bundle
SQL Migrations Bundle
A Symfony bundle for database versioning, using only plain SQL files.
Allows maintaining a database schema without using the Doctrine ORM entities system.
Installation
Prerequisites:
- PHP >= 8.4
- Symfony 7.4.*
- PostgreSQL using the public schema (not compatible with other databases for now)
Step 1: Prepare your project
If you start with a fresh Symfony skeleton, you will need Doctrine to install the bundle.
Install the ORM-pack (it's the only way to have \Connection services properly configured):
We don't need the ORM parts; you can clean up your project:
- remove
src/Entityandsrc/Repositoryfolders - in the
config/packages/doctrine.yaml, keep only thedoctrine.dbalparts
Step 2: Download the Bundle
Open a command console, enter your project directory, and execute the following command to download the latest stable version of this bundle:
Usage
Step 1: Put your .sql migration files in a migrations directory at the root of your project
The order of the files is important, the bundle will execute them in the order of their names.
I recommend adding the date in the filename, like YYYYMMDD_[feature].sql, to keep track of the order.
There is no down migration system.
Step 2: Run the command to apply the migrations
That command will execute all the SQL files in the migrations directory that have not been executed yet.
The --dry-run option will only display the SQL queries that will be executed. Remove the option to execute the queries.
You can add the --drop-database option to drop the database (the public schema) before applying the migrations (useful for local/dev environment).
That command will use an internal table _migrations in the database to keep track of the applied migrations. You can change the name of the table by setting the SQL_MIGRATIONS_TABLE environment variable.
Other commands
Mark a migration as applied without executing it:
Reset the _migration table and mark all migrations as applied without executing them:
Development
Clone the repository :
Run tests locally
With Docker
The docker stack includes the PHP runtime and the PostgreSQL database.
Without Docker
Prequisites:
- Php 8.4 / Composer
- A running PostgreSQL database
- A dedicated database for tests
Create a .env.test.local file and adapt the DATABASE_URL variable to your configuration:
Run tests:
All versions of sql-migrations-bundle with dependencies
symfony/framework-bundle Version 7.4.*
symfony/console Version 7.4.*
doctrine/dbal Version ^4.0