| author | cavaliet |
| Mon, 07 Jul 2014 17:23:47 +0200 | |
| changeset 122 | d672f7dd74dc |
| parent 39 | 03b14b0fe101 |
| permissions | -rw-r--r-- |
|
39
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
DoctrineMigrationsBundle |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
======================== |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
The database migrations feature is an extension of the database abstraction |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
layer and offers you the ability to programmatically deploy new versions of |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
your database schema in a safe, easy and standardized way. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
.. tip:: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
You can read more about the Doctrine Database Migrations on the project's |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
`documentation`_. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
Installation |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
------------ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
Doctrine migrations for Symfony are maintained in the `DoctrineMigrationsBundle`_. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
Make sure you have both the ``doctrine-migrations`` and ``DoctrineMigrationsBundle`` |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
libraries configured in your project. Follow these steps to install the |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
libraries in the Symfony Standard distribution. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
Add the following to ``deps``. This will register the Migrations Bundle |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
and the doctrine-migrations library as dependencies in your application: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
.. code-block:: text |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
[doctrine-migrations] |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
git=http://github.com/doctrine/migrations.git |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
[DoctrineMigrationsBundle] |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
git=http://github.com/symfony/DoctrineMigrationsBundle.git |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
target=/bundles/Symfony/Bundle/DoctrineMigrationsBundle |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
Update the vendor libraries: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
.. code-block:: bash |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
$ php bin/vendors install |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
Next, ensure the new ``Doctrine\DBAL\Migrations`` namespace will be autoloaded |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
via ``autoload.php``. The new ``Migrations`` namespace *must* be placed above |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
the ``Doctrine\\DBAL`` entry so that the autoloader looks inside the migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
directory for those classes: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
.. code-block:: php |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
// app/autoload.php |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
$loader->registerNamespaces(array( |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
//... |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
'Doctrine\\DBAL\\Migrations' => __DIR__.'/../vendor/doctrine-migrations/lib', |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib', |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
)); |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
Finally, be sure to enable the bundle in ``AppKernel.php`` by including the |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
following: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
.. code-block:: php |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
57 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
// app/AppKernel.php |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
public function registerBundles() |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
{ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
$bundles = array( |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
//... |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
new Symfony\Bundle\DoctrineMigrationsBundle\DoctrineMigrationsBundle(), |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
); |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
65 |
} |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
66 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
Usage |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
----- |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
All of the migrations functionality is contained in a few console commands: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
.. code-block:: bash |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
doctrine:migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
:diff Generate a migration by comparing your current database to your mapping information. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
:execute Execute a single migration version up or down manually. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
:generate Generate a blank migration class. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
78 |
:migrate Execute a migration to a specified version or the latest available version. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
:status View the status of a set of migrations. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
:version Manually add and delete migration versions from the version table. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
Start by getting the status of migrations in your application by running |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
the ``status`` command: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
85 |
.. code-block:: bash |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
php app/console doctrine:migrations:status |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
89 |
== Configuration |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
>> Name: Application Migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
92 |
>> Configuration Source: manually configured |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
>> Version Table Name: migration_versions |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
>> Migrations Namespace: Application\Migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
95 |
>> Migrations Directory: /path/to/project/app/DoctrineMigrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
96 |
>> Current Version: 0 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
>> Latest Version: 0 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
98 |
>> Executed Migrations: 0 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
>> Available Migrations: 0 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
>> New Migrations: 0 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
Now, you can start working with migrations by generating a new blank migration |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
class. Later, you'll learn how Doctrine can generate migrations automatically |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
for you. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
106 |
.. code-block:: bash |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
php app/console doctrine:migrations:generate |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
109 |
Generated new migration class to "/path/to/project/app/DoctrineMigrations/Version20100621140655.php" |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
Have a look at the newly generated migration class and you will see something |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
112 |
like the following:: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
namespace Application\Migrations; |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
use Doctrine\DBAL\Migrations\AbstractMigration, |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
Doctrine\DBAL\Schema\Schema; |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
class Version20100621140655 extends AbstractMigration |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
{ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
public function up(Schema $schema) |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
{ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
} |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
public function down(Schema $schema) |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
{ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
} |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
} |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
If you run the ``status`` command it will now show that you have one new |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
migration to execute: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
134 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
135 |
.. code-block:: bash |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
137 |
php app/console doctrine:migrations:status |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
138 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
139 |
== Configuration |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
140 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
141 |
>> Name: Application Migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
142 |
>> Configuration Source: manually configured |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
143 |
>> Version Table Name: migration_versions |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
144 |
>> Migrations Namespace: Application\Migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
145 |
>> Migrations Directory: /path/to/project/app/DoctrineMigrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
146 |
>> Current Version: 0 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
147 |
>> Latest Version: 2010-06-21 14:06:55 (20100621140655) |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
>> Executed Migrations: 0 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
149 |
>> Available Migrations: 1 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
150 |
>> New Migrations: 1 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
151 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
== Migration Versions |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
>> 2010-06-21 14:06:55 (20100621140655) not migrated |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
155 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
Now you can add some migration code to the ``up()`` and ``down()`` methods and |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
finally migrate when you're ready: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
158 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
.. code-block:: bash |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
160 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
161 |
php app/console doctrine:migrations:migrate |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
162 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
For more information on how to write the migrations themselves (i.e. how to |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
164 |
fill in the ``up()`` and ``down()`` methods), see the official Doctrine Migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
165 |
`documentation`_. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
167 |
Running Migrations during Deployment |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
169 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
170 |
Of course, the end goal of writing migrations is to be able to use them to |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
171 |
reliably update your database structure when you deploy your application. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
172 |
By running the migrations locally (or on a beta server), you can ensure that |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
173 |
the migrations work as you expect. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
174 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
175 |
When you do finally deploy your application, you just need to remember to run |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
176 |
the ``doctrine:migrations:migrate`` command. Internally, Doctrine creates |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
177 |
a ``migration_versions`` table inside your database and tracks which migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
178 |
have been executed there. So, no matter how many migrations you've created |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
179 |
and executed locally, when you run the command during deployment, Doctrine |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
180 |
will know exactly which migrations it hasn't run yet by looking at the ``migration_versions`` |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
table of your production database. Regardless of what server you're on, you |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
can always safely run this command to execute only the migrations that haven't |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
183 |
been run yet on *that* particular database. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
184 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
Generating Migrations Automatically |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
----------------------------------- |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
187 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
188 |
In reality, you should rarely need to write migrations manually, as the migrations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
189 |
library can generate migration classes automatically by comparing your Doctrine |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
mapping information (i.e. what your database *should* look like) with your |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
191 |
actual current database structure. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
193 |
For example, suppose you create a new ``User`` entity and add mapping information |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
for Doctrine's ORM: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
196 |
.. configuration-block:: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
197 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
198 |
.. code-block:: php-annotations |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
200 |
// src/Acme/HelloBundle/Entity/User.php |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
201 |
namespace Acme\HelloBundle\Entity; |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
202 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
203 |
use Doctrine\ORM\Mapping as ORM; |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
204 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
205 |
/** |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
206 |
* @ORM\Entity |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
207 |
* @ORM\Table(name="hello_user") |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
208 |
*/ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
209 |
class User |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
210 |
{ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
211 |
/** |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
212 |
* @ORM\Id |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
213 |
* @ORM\Column(type="integer") |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
214 |
* @ORM\GeneratedValue(strategy="AUTO") |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
215 |
*/ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
216 |
protected $id; |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
217 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
218 |
/** |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
219 |
* @ORM\Column(type="string", length="255") |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
220 |
*/ |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
221 |
protected $name; |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
222 |
} |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
223 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
224 |
.. code-block:: yaml |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
225 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
226 |
# src/Acme/HelloBundle/Resources/config/doctrine/User.orm.yml |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
227 |
Acme\HelloBundle\Entity\User: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
228 |
type: entity |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
229 |
table: hello_user |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
230 |
id: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
231 |
id: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
232 |
type: integer |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
233 |
generator: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
234 |
strategy: AUTO |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
235 |
fields: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
236 |
name: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
237 |
type: string |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
238 |
length: 255 |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
239 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
240 |
.. code-block:: xml |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
241 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
242 |
<!-- src/Acme/HelloBundle/Resources/config/doctrine/User.orm.xml --> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
243 |
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
244 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
245 |
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
246 |
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
247 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
248 |
<entity name="Acme\HelloBundle\Entity\User" table="hello_user"> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
249 |
<id name="id" type="integer" column="id"> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
250 |
<generator strategy="AUTO"/> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
251 |
</id> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
252 |
<field name="name" column="name" type="string" length="255" /> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
253 |
</entity> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
254 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
255 |
</doctrine-mapping> |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
256 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
257 |
With this information, Doctrine is now ready to help you persist your new |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
258 |
``User`` object to and from the ``hello_user`` table. Of course, this table |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
259 |
doesn't exist yet! Generate a new migration for this table automatically by |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
260 |
running the following command: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
261 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
262 |
.. code-block:: bash |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
263 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
264 |
php app/console doctrine:migrations:diff |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
265 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
266 |
You should see a message that a new migration class was generated based on |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
267 |
the schema differences. If you open this file, you'll find that it has the |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
268 |
SQL code needed to create the ``hello_user`` table. Next, run the migration |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
269 |
to add the table to your database: |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
270 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
271 |
.. code-block:: bash |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
272 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
273 |
php app/console doctrine:migrations:migrate |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
274 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
275 |
The moral of the story is this: after each change you make to your Doctrine |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
276 |
mapping information, run the ``doctrine:migrations:diff`` command to automatically |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
277 |
generate your migration classes. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
278 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
279 |
If you do this from the very beginning of your project (i.e. so that even |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
280 |
the first tables were loaded via a migration class), you'll always be able |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
281 |
to create a fresh database and run your migrations in order to get your database |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
282 |
schema fully up to date. In fact, this is an easy and dependable workflow |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
283 |
for your project. |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
284 |
|
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
285 |
.. _documentation: http://www.doctrine-project.org/projects/migrations/2.0/docs/reference/introduction/en |
|
03b14b0fe101
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
286 |
.. _DoctrineMigrationsBundle: https://github.com/symfony/DoctrineMigrationsBundle |