Skip to content

Commit 9f34d2c

Browse files
committed
Adding default support for dbal-fuild-schema-builder in migration patcher.
1 parent d6b762b commit 9f34d2c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"mouf/database.doctrine-dbal-wrapper": "^1.0",
1818
"mouf/utils.patcher": "^2.0",
1919
"mouf/classname-mapper": "^1.0",
20-
"symfony/filesystem": "^2.0 || ^3.0"
20+
"symfony/filesystem": "^2.0 || ^3.0",
21+
"thecodingmachine/dbal-fluid-schema-builder": "^1.0"
2122
},
2223
"autoload": {
2324
"psr-0": {

src/Mouf/Database/Patcher/Controllers/MigrationPatchController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public function save($name, $selfedit,
104104
105105
use Doctrine\DBAL\Schema\Schema;
106106
use Mouf\Database\Patcher\AbstractSchemaMigrationPatch;
107+
use TheCodingMachine\FluidSchema;
108+
107109
108110
/**
109111
* This class is a patch used to apply changes to the database.
@@ -112,12 +114,26 @@ class $shortClassName extends AbstractSchemaMigrationPatch
112114
{
113115
public function up(Schema \$schema) : void
114116
{
117+
\$db = new FluidSchema(\$schema);
115118
// Code your migration here.
119+
//
120+
// \$db->table('users')
121+
// ->id() // Create an 'id' primary key that is an autoincremented integer
122+
// ->column('login')->string(50)->unique()->then() // Create a login column with a "unique" index
123+
// ->column('photo_url')->string(50)->null()->then() // Create a nullable 'photo_url' column
124+
// ->column('country_id')->references('countries') // Create a foreign key on the 'countries' table
125+
//
126+
// \$db->junctionTable('users', 'roles'); // Create a 'users_roles' junction table between 'users' and 'roles'.
127+
128+
// More documentation here: https://github.com/thecodingmachine/dbal-fluid-schema-builder
129+
// and here: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-representation.html
116130
}
117131
118132
public function down(Schema \$schema) : void
119133
{
120134
// Code your migration cancellation code here.
135+
//
136+
// \$db->dropTable('users');
121137
}
122138
123139
public function getDescription(): string

0 commit comments

Comments
 (0)