Jump to conversation
Unresolved conversations (1)
@pwizla pwizla May 10, 2022
```suggestion - The `down()` function is used to reverse the `up()` function when downgrading (e.g. deleting `my_new_table`). ```
Outdated
...eveloper-resources/database-migrations.md
Resolved conversations (16)
@pwizla pwizla Oct 6, 2022
```suggestion ```
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla Oct 6, 2022
```suggestion Migration files should export the function `up()`, which is used when upgrading (e.g. adding a new table `my_new_table`). ```
Outdated
...eveloper-resources/database-migrations.md
@derrickmehaffy derrickmehaffy May 17, 2022
Should we add await here also?
Outdated
...eveloper-resources/database-migrations.md
@derrickmehaffy derrickmehaffy May 17, 2022
Should we add await here also?
Outdated
...eveloper-resources/database-migrations.md
@derrickmehaffy derrickmehaffy May 10, 2022
more odd symbols int he functions
Outdated
...eveloper-resources/database-migrations.md
@derrickmehaffy derrickmehaffy May 10, 2022
I'd recommend we offer a more complete example, and I believe we are passing in knex in it's entirety not just transactions. See this example from the repo I've been referencing about this until we added the docs for it: https://github.com/derrickmehaffy/strapi-example-v4-custom-db/blob/main/database/migrations/test.js This also doesn't cover the fact you can add .sql files here as well such as in my example here: https://github.com/derrickmehaffy/strapi-example-v4-custom-db/blob/main/database/migrations/testSQL.sql.example
...eveloper-resources/database-migrations.md
petersg83
Pierre Noël
@derrickmehaffy derrickmehaffy May 10, 2022
More odd symbols here that should probably be removed
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla May 10, 2022
```suggestion 3. Fill in the template by adding actual migration code inside the `up()` and `down()` functions. ```
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla May 10, 2022
```suggestion 2. Copy and paste the following template in the previously created file: ```
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla May 10, 2022
```suggestion To create a migration file: 1. In the `./database/migrations` folder, create a new file named after the date and the name of the migration (e.g. `2022.05.10T00.00.00.name-of-my-migration.js`). Make sure that the file name follows this naming pattern, because the alphabetical order of the files defines the order in which the migrations have to run. ```
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla May 10, 2022
```suggestion There is no CLI to run the migration manually for the moment. ```
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla May 10, 2022
```suggestion Strapi will automatically detect migration files and run them once at the next startup in alphabetical order. Every new file is executed once. ```
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla May 10, 2022
```suggestion - The `up()` function is used when upgrading (e.g. adding a new table `my_new_table`). ```
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla May 10, 2022
```suggestion Migration files should export 2 functions `up()` and `down()`: ```
Outdated
...eveloper-resources/database-migrations.md
pwizla derrickmehaffy
Pierre Wizla and DMehaffy
@pwizla pwizla May 10, 2022
```suggestion Migrations are run using JavaScript migration files stored in `./database/migrations`. ```
Outdated
...eveloper-resources/database-migrations.md
@pwizla pwizla May 10, 2022
```suggestion Database migrations exist to run one-time queries against the database, typically to modify the tables structure or the data when upgrading the Strapi application. ```
Outdated
...eveloper-resources/database-migrations.md