1
1
DoctrineMigrationsBundle
2
2
========================
3
3
4
- The database migrations feature is an extension of the database abstraction
5
- layer and offers you the ability to programmatically deploy new versions of
6
- your database schema in a safe, easy and standardized way .
4
+ Lastnost migracije podatkovne baze je razširitev nivoja abstrakcije podatkovne
5
+ baze in vam ponuja možnost programsko naložiti nove verzije
6
+ sheme vaše podatkovne baze na varen, enostaven in standardiziran način .
7
7
8
8
.. tip ::
9
9
10
- You can read more about the Doctrine Database Migrations on the project's
11
- `documentation `_.
10
+ Več o migracijah podatkovnih baz Doctrine lahko preberete v projektni
11
+ `dokumentaciji `_.
12
12
13
- Installation
14
- ------------
13
+ Namestitev
14
+ ----------
15
15
16
- Doctrine migrations for Symfony are maintained in the `DoctrineMigrationsBundle `_.
17
- The bundle uses external `Doctrine Database Migrations `_ library .
16
+ Migracije Doctrine za Symfony so vzdrževane v `DoctrineMigrationsBundle `_.
17
+ Paket uporablja zunanjo knjižnico `Doctrine Database Migrations `_.
18
18
19
- Follow these steps to install the bundle and the library in the Symfony
20
- Standard edition. Add the following to your ``composer.json `` file :
19
+ Sledite tem korakom, da namestite paket in knjižnico v Symfony
20
+ standardno izdajo. Dodajte sledeče v vašo datoteko ``composer.json ``:
21
21
22
22
.. code-block :: json
23
23
@@ -28,23 +28,23 @@ Standard edition. Add the following to your ``composer.json`` file:
28
28
}
29
29
}
30
30
31
- Update the vendor libraries :
31
+ Posodobite knjižnice vendor:
32
32
33
33
.. code-block :: bash
34
34
35
35
$ php composer.phar update
36
36
37
- If everything worked, the ``DoctrineMigrationsBundle `` can now be found
38
- at ``vendor/doctrine/doctrine-migrations-bundle ``.
37
+ Če je vse delovalo, je ``DoctrineMigrationsBundle `` sedaj na voljo
38
+ v ``vendor/doctrine/doctrine-migrations-bundle ``.
39
39
40
40
.. note ::
41
41
42
42
``DoctrineMigrationsBundle `` installs
43
43
`Doctrine Database Migrations `_ library. The library can be found
44
44
at ``vendor/doctrine/migrations ``.
45
45
46
- Finally, be sure to enable the bundle in ``AppKernel.php `` by including the
47
- following :
46
+ Na koncu se prepričajte, da ste omogočili paket v ``AppKernel.php `` z vključitvijo
47
+ sledečega :
48
48
49
49
.. code-block :: php
50
50
@@ -56,11 +56,11 @@ following:
56
56
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
57
57
);
58
58
}
59
-
60
- Configuration
61
- -------------
62
59
63
- You can configure the path, namespace, table_name and name in your `config.yml `. The examples below are the default values.
60
+ Nastavitve
61
+ ----------
62
+
63
+ Nastavite lahko pot, imenski prostor, ime tabele in ime v vaši ``config.yml ``. Primeri spodaj so privzete vrednosti.
64
64
65
65
.. code-block :: yaml
66
66
@@ -69,12 +69,12 @@ You can configure the path, namespace, table_name and name in your `config.yml`.
69
69
dir_name : %kernel.root_dir%/DoctrineMigrations
70
70
namespace : Application\Migrations
71
71
table_name : migration_versions
72
- name : Application Migrations
72
+ name : Application Migrations
73
73
74
- Usage
75
- -----
74
+ Uporaba
75
+ -------
76
76
77
- All of the migrations functionality is contained in a few console commands :
77
+ Vsa funkcionalnost migracij je vsebovana v nekaj konzolnih ukazih :
78
78
79
79
.. code-block :: bash
80
80
@@ -86,8 +86,8 @@ All of the migrations functionality is contained in a few console commands:
86
86
:status View the status of a set of migrations.
87
87
:version Manually add and delete migration versions from the version table.
88
88
89
- Start by getting the status of migrations in your application by running
90
- the ``status `` command :
89
+ Začnite s pridobitvijo statusa migracij v vaši aplikaciji s pogonom
90
+ ukaza ``status ``:
91
91
92
92
.. code-block :: bash
93
93
@@ -106,17 +106,17 @@ the ``status`` command:
106
106
>> Available Migrations: 0
107
107
>> New Migrations: 0
108
108
109
- Now, you can start working with migrations by generating a new blank migration
110
- class. Later, you'll learn how Doctrine can generate migrations automatically
111
- for you .
109
+ Sedaj lahko začnete delati z migracijami z generiranjem novega praznega migracijskega
110
+ razreda. Kasneje se boste naučili, kako lahko Doctrine generira migracije avtomatično
111
+ za vas .
112
112
113
113
.. code-block :: bash
114
114
115
115
php app/console doctrine:migrations:generate
116
116
Generated new migration class to " /path/to/project/app/DoctrineMigrations/Version20100621140655.php"
117
117
118
- Have a look at the newly generated migration class and you will see something
119
- like the following ::
118
+ Poglejte novo generirani migracijski razred in videli boste nekaj,
119
+ kot je sledeče ::
120
120
121
121
namespace Application\Migrations;
122
122
@@ -136,8 +136,8 @@ like the following::
136
136
}
137
137
}
138
138
139
- If you run the ``status `` command it will now show that you have one new
140
- migration to execute :
139
+ Če poženete ukaz ``status `` bo sedaj pokazal, da imate eno novo
140
+ migracijo za izvršiti :
141
141
142
142
.. code-block :: bash
143
143
@@ -160,45 +160,45 @@ migration to execute:
160
160
161
161
>> 2010-06-21 14:06:55 (20100621140655) not migrated
162
162
163
- Now you can add some migration code to the ``up() `` and ``down() `` methods and
164
- finally migrate when you're ready :
163
+ Sedaj lahko dodate nekaj kode migracije k metodam ``up() `` in ``down() `` ter
164
+ končno migrirate, ko ste pripravljeni :
165
165
166
166
.. code-block :: bash
167
167
168
168
php app/console doctrine:migrations:migrate 20100621140655
169
169
170
- For more information on how to write the migrations themselves (i.e. how to
171
- fill in the ``up() `` and ``down() `` methods ), see the official Doctrine Migrations
172
- `documentation `_ .
170
+ Za več informacij, kako pisati same migracije (t.j. kako
171
+ zapolniti metodi ``up() `` in ``down() ``), glejte uradno
172
+ `dokumentacijo `_ Doctrine migracije .
173
173
174
- Running Migrations during Deployment
175
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
174
+ Poganjanje migracij med razvojem
175
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176
176
177
- Of course, the end goal of writing migrations is to be able to use them to
178
- reliably update your database structure when you deploy your application .
179
- By running the migrations locally (or on a beta server ), you can ensure that
180
- the migrations work as you expect .
177
+ Seveda končni cilj pisanja migracij je, biti jih sposoben uporabiti, da
178
+ zanesljivo posodobijo strukturo vaše podatkovne baze, ko nalagate vašo aplikacijo .
179
+ S pogonom migracij lokalno (ali na beta strežniku ), lahko zagotovite, da
180
+ migracije delujejo, kot pričakujete .
181
181
182
- When you do finally deploy your application, you just need to remember to run
183
- the ``doctrine:migrations:migrate `` command. Internally , Doctrine creates
184
- a ``migration_versions `` table inside your database and tracks which migrations
185
- have been executed there. So, no matter how many migrations you've created
186
- and executed locally, when you run the command during deployment, Doctrine
187
- will know exactly which migrations it hasn't run yet by looking at the `` migration_versions ``
188
- table of your production database. Regardless of what server you're on, you
189
- can always safely run this command to execute only the migrations that haven't
190
- been run yet on * that * particular database .
182
+ Ko končno naložite vašo aplikacijo, si morate samo zapomniti pognati
183
+ ukaz ``doctrine:migrations:migrate ``. Interno , Doctrine izdela
184
+ tabelo ``migration_versions `` znotraj vaše podatkovne baze in beleži katere migracije
185
+ so bile tam izvršene. Torej ne glede na to, koliko migracij ste ustvarili
186
+ in izvršili lokalno, ko poženete ukaz med razvojem, bo Doctrine
187
+ točno vedel, katere migracije še niso bile pognane s pogledom v tabelo
188
+ `` migration_versions `` vaše produkcijske baze. Ne glede na to, na katerem strežniku ste,
189
+ lahko vedno varno poženete ta ukaz, da izvršite samo migracije, ki še niso bile
190
+ pognane na * tisti * določeni podatkovni bazi .
191
191
192
- Generating Migrations Automatically
193
- -----------------------------------
192
+ Avtomatično generiranje migracij
193
+ --------------------------------
194
194
195
- In reality, you should rarely need to write migrations manually, as the migrations
196
- library can generate migration classes automatically by comparing your Doctrine
197
- mapping information (i.e. what your database * should * look like) with your
198
- actual current database structure .
195
+ V realnosti bi morali redko potrebovati pisati migracije ročno, saj knjižnica
196
+ migracij lahko generira razrede migracij avtomatično s primerjanjem vaših informacij Doctrine
197
+ preslikav (t.j. kako bi vaša podatkovna baza * morala * izgledati) z vašo
198
+ dejansko trenutno strukturo podatke baze .
199
199
200
- For example, suppose you create a new ``User `` entity and add mapping information
201
- for Doctrine's ORM:
200
+ Na primer, predpostavimo, da ste ustvarili novo entiteto ``User `` in dodali informacije preslikav
201
+ za Doctrine-ov ORM:
202
202
203
203
.. configuration-block ::
204
204
@@ -261,43 +261,43 @@ for Doctrine's ORM:
261
261
262
262
</doctrine-mapping >
263
263
264
- With this information , Doctrine is now ready to help you persist your new
265
- ``User `` object to and from the ``hello_user `` table. Of course, this table
266
- doesn't exist yet! Generate a new migration for this table automatically by
267
- running the following command :
264
+ S temi informacijami , Doctrine je sedaj pripravljen, da vam pomaga pridobiti vaš novi
265
+ objekt ``User `` v in iz tabele ``hello_user ``. Seveda ta tabela
266
+ še ne obstaja! Generirajte novo migracijo za to tabelo avtomatično s
267
+ pogonom sledečega ukaza :
268
268
269
269
.. code-block :: bash
270
270
271
271
php app/console doctrine:migrations:diff
272
272
273
- You should see a message that a new migration class was generated based on
274
- the schema differences. If you open this file, you'll find that it has the
275
- SQL code needed to create the ``hello_user `` table. Next, run the migration
276
- to add the table to your database :
273
+ Sedaj bi morali videti sporočilo, da je bil generiran razred nove migracije na osnovi
274
+ razlik sheme. Če odprete to datoteko, boste ugotovili, da ima
275
+ kodo SQL, ki je potrebna za ustvariti tabelo ``hello_user ``. Naslednje poženite migracijo,
276
+ da dodate tabelo vaši podatkovni bazi :
277
277
278
278
.. code-block :: bash
279
279
280
280
php app/console doctrine:migrations:migrate
281
281
282
- The moral of the story is this: after each change you make to your Doctrine
283
- mapping information, run the ``doctrine:migrations:diff `` command to automatically
284
- generate your migration classes .
282
+ Morala te zgodbe je: po vsaki spremembi, ki jo naredite vašim informacijam
283
+ Doctrine preslikav, poženite ukaz ``doctrine:migrations:diff ``, da avtomatično
284
+ generirate vaše razrede migracij .
285
285
286
- If you do this from the very beginning of your project (i.e. so that even
287
- the first tables were loaded via a migration class ), you'll always be able
288
- to create a fresh database and run your migrations in order to get your database
289
- schema fully up to date. In fact, this is an easy and dependable workflow
290
- for your project .
286
+ Če to delate od samega začetka vašega projekta (t.j. da celo
287
+ ko so naložene prve tabele preko migracijskega razreda ), boste vedno sposobni
288
+ ustvariti svežo podatkovno bazo in pognati vaše migracije, da dobite shemo
289
+ vaše podatkovne baze v celoti posodobljeno. V bistvu je to enostaven in odvisen potek dela
290
+ za vaš projekt .
291
291
292
- Container Aware Migrations
293
- --------------------------
292
+ Migracije, ki se zavedajo kontejnerja
293
+ -------------------------------------
294
294
295
- In some cases you might need access to the container to ensure the proper update of
296
- your data structure. This could be necessary to update relations with some specific
297
- logic or to create new entities.
295
+ V nekaterih primerih boste morda potrebovali dostop do kontejnerja, da zagovotite ustrezno posodobitev
296
+ strukture vaše podatkovne baze. To je lahko potrebno za posodobitev relacij z nekatero določeno
297
+ logiko ali ustvariti nove entitete.
298
298
299
- Therefore you can just implement the ContainerAwareInterface with its needed methods
300
- to get full access to the container .
299
+ Zato lahko samo implementirate ContainerAwareInterface z njegovimi potrebnimi metodami,
300
+ da dobite celotni dostop do kontejnerja .
301
301
302
302
.. code-block :: php
303
303
@@ -307,52 +307,52 @@ to get full access to the container.
307
307
308
308
class Version20130326212938 extends AbstractMigration implements ContainerAwareInterface
309
309
{
310
-
310
+
311
311
private $container;
312
-
312
+
313
313
public function setContainer(ContainerInterface $container = null)
314
314
{
315
315
$this->container = $container;
316
316
}
317
-
317
+
318
318
public function up(Schema $schema)
319
319
{
320
320
// ... migration content
321
321
}
322
-
322
+
323
323
public function postUp(Schema $schema)
324
324
{
325
325
$em = $this->container->get('doctrine.orm.entity_manager');
326
326
// ... update the entities
327
327
}
328
328
}
329
329
330
- Manual Tables
331
- -------------
330
+ Ročne tabele
331
+ ------------
332
332
333
- It is a common use case, that in addition to your generated database structure
334
- based on your doctrine entities you might need custom tables. By default such
335
- tables will be removed by the doctrine:migrations: diff command .
333
+ Pogosti primer uporabe je, da kot dodatek k strukturi vaše generirane podatkovne baze
334
+ na osnovi vaših entitet doctrine, lahko potrebujete prilagoditi tabele. Privzeto bodo take
335
+ tabele odstranjene z ukazom doctrine:migrations: diff.
336
336
337
- If you follow a specific scheme you can configure doctrine/dbal to ignore those
338
- tables. Let's say all custom tables will be prefixed by ``t_ ``. In this case you
339
- just have to add the following configuration option to your doctrine configuration :
337
+ Če sledite določeni shemi, lahko nastavite doctrine/dbal, da ignorira te
338
+ tabele. Predpostavimo, da bodo vse tabele po meri imele predpono ``t_ ``. V tem primeru
339
+ morate dodati samo naslednjo nastavitveno opcijo v vaše nastavitve doctrine:
340
340
341
341
.. configuration-block ::
342
342
343
343
.. code-block :: yaml
344
-
344
+
345
345
doctrine :
346
- dbal :
346
+ dbal :
347
347
schema_filter : ~^(?!t_)~
348
-
348
+
349
349
.. code-block :: xml
350
-
350
+
351
351
<doctrine : dbal schema-filter =" ~^(?!t_)~" ... />
352
352
353
-
353
+
354
354
.. code-block :: php
355
-
355
+
356
356
$container->loadFromExtension('doctrine', array(
357
357
'dbal' => array(
358
358
'schema_filter' => '~^(?!t_)~',
@@ -361,11 +361,12 @@ just have to add the following configuration option to your doctrine configurati
361
361
// ...
362
362
));
363
363
364
- This ignores the tables on the DBAL level and they will be ignored by the diff command .
364
+ To ignorira tabele na nivoju DBAL in bodo ignorirane s strani ukaza diff.
365
365
366
- Note that if you have multiple connections configured then the ``schema_filter `` configuration
367
- will need to be placed per-connection .
366
+ Bodite pozorni, da če imate nastavljenih več povezav, potem bodo nastavitve ``schema_filter ``
367
+ potrebne za postaviti na povezavo .
368
368
369
- .. _documentation : http://docs.doctrine-project.org/projects/doctrine-migrations/en/latest/index.html
369
+ .. _dokumentacijo : http://docs.doctrine-project.org/projects/doctrine-migrations/en/latest/index.html
370
+ .. _dokumentaciji : http://docs.doctrine-project.org/projects/doctrine-migrations/en/latest/index.html
370
371
.. _DoctrineMigrationsBundle : https://github.com/doctrine/DoctrineMigrationsBundle
371
372
.. _`Doctrine Database Migrations` : https://github.com/doctrine/migrations
0 commit comments