Updating schema

The Laravel Some migration operations are destructive, which means they may cause you to lose data.In order to protect you from running these commands against your production database, you will be prompted for confirmation before the commands are executed.Afterwards, you can use the methods of the table schema class to modify the table according to your needs, e.g.Sometimes you might need to use column or index options that are only available for specific database servers, e.g. While you can create those indexes without problems in your own setup task, DBAL would try to change your column or index during every setup run.

This setup task must extend from the existing MShop Create Tables (or MAdmin Create Tables) setup task: In the clean() and migrate() methods, you have to call the setup Schema() method from the parent class with the file that contains your schema definition.

This enables your extension to add additional columns or indexes to core tables or change column options like their length or type.

Your changes will be applied to the tables while the setup tasks are running as long as your extension is installed.

Migrations are typically paired with Laravel's schema builder to easily build your application's database schema.

If you have ever had to tell a teammate to manually add a column to their local database schema, you've faced the problem that database migrations solve.

Leave a Reply