Skip to content

Commit 3ce9403

Browse files
committed
Issue #133: Added instructions to create migration
Signed-off-by: alexmerlin <[email protected]>
1 parent c4f9020 commit 3ce9403

File tree

1 file changed

+48
-8
lines changed

1 file changed

+48
-8
lines changed

docs/book/v6/installation/doctrine-orm.md

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
11
# Doctrine ORM
22

3-
## Setup database
3+
This step saves the database connection credentials in an API configuration file.
4+
We do not cover the creation steps of the database itself.
45

5-
Use an existing empty one or create a new **MariaDB**/**MySQL** database.
6+
## Setup database
67

7-
> Recommended collation: `utf8mb4_general_ci`.
8+
Create a new **MariaDB**/**MySQL** database and set its collation to `utf8mb4_general_ci`.
9+
10+
Make sure you fill out the database credentials in `config/autoload/local.php` under `$databases['default']`.
11+
Below is the item you need to focus on:
12+
13+
```php
14+
$databases = [
15+
'default' => [
16+
'host' => 'localhost',
17+
'dbname' => 'my_database',
18+
'user' => 'my_user',
19+
'password' => 'my_password',
20+
'port' => 3306,
21+
'driver' => 'pdo_mysql',
22+
'charset' => 'utf8mb4',
23+
'collate' => 'utf8mb4_general_ci',
24+
],
25+
// you can add more database connections into this array
26+
];
27+
```
828

9-
With a database created, fill out the database connection params in `config/autoload/local.php` under `$databases['default']`.
29+
> `my_database`, `my_user`, `my_password` are provided only as an example.
1030
1131
### Creating migrations
1232

13-
Create a new migration by running:
33+
Create a database migration by executing the following command:
1434

1535
```shell
1636
php ./vendor/bin/doctrine-migrations diff
@@ -20,17 +40,37 @@ The new migration file will be placed in `src/Core/src/App/src/Migration/`.
2040

2141
### Running migrations
2242

23-
Execute a new migration by running:
43+
Run the database migrations by executing the following command:
2444

2545
```shell
2646
php ./vendor/bin/doctrine-migrations migrate
2747
```
2848

29-
This command will prompt you to confirm that you want to run it:
49+
> If you have already run the migrations, you may get the below message:
50+
51+
```text
52+
WARNING! You have x previously executed migrations in the database that are not registered migrations.
53+
{migration list}
54+
Are you sure you wish to continue? (y/n)
55+
```
56+
57+
> In this case, you should double-check to make sure the new migrations are ok to run.
3058
31-
> WARNING! You are about to execute a migration in database "..." that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
59+
When using an empty database, you will get this confirmation message:
60+
61+
```text
62+
WARNING! You are about to execute a migration in database "<your_database_name>" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no)
63+
```
3264

3365
Hit `Enter` to confirm the operation.
66+
This will run all the migrations in chronological order.
67+
Each migration will be logged in the `migrations` table to prevent running the same migration more than once, which is often not desirable.
68+
69+
If everything ran correctly, you will get this confirmation.
70+
71+
```text
72+
[OK] Successfully migrated to version: Core\App\Migration\VersionYYYYMMDDHHMMSS
73+
```
3474

3575
### Executing fixtures
3676

0 commit comments

Comments
 (0)