# Tag: Migrations

## CakePHP 3: Kurzfassung zum Verwenden von Migrations

CakePHP bietet mit Migrations die Möglichkeit, Änderungen an der Datenbankstruktur einzuspielen oder rückgängig zu machen. Der typische Ablauf zur Migration ist folgender:

## Generating migrations from an existing database

If you are dealing with a pre-existing database and want to start using migrations, or to version control the initial schema of your application’s database, you can run the migration_snapshot command:

bin/cake bake migration_snapshot Initial

## Generating a diff between two database states

You can generate a migrations file that will group all the differences between two database states using the migration_diff bake template. To do so, you can use the following command:

bin/cake bake migration_diff NameOfTheMigrations

## Applying Migrations

Once you have generated or written your migration file, you need to execute the following command to apply the changes to your database:

bin/cake migrations migrate

## Migrations Status

The Status command prints a list of all migrations, along with their current status. You can use this command to determine which migrations have been run:

bin/cake migrations status