Now that you have installed the new database package. You need to update your `database.json` configuration files located in `./config/environments/{env}/database.json`.
You can now only use the connector name instead of the complete package name.
**Before**
```json
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-hook-bookshelf",
"settings": {
//...
},
"options": {}
}
}
}
```
**After**
```json
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "bookshelf",
"settings": {
//...
},
"options": {
//...
}
}
}
}
```
## `ctx.state.user`
Previously the ctx.state.user was populated with the user informations, its role and permissions. To avoid perfromance issues the role is the only populated relation on the user by default.
## File model
The file model has been update. The `size` field is now a decimal number, allowing correct sorting behavior.
You will need to clear some database indexes if you are using either Mysql or PostgreSQL.
:::: tabs
::: tab Mysql
Run the following statement in your database:
`DROP INDEX SEARCH_UPLOAD_FILE ON upload_file;`
:::
::: tab PostgreSQL
Run the following statement in your database:
`DROP INDEX search_upload_file_size;`
:::
::::
## Groups become Components
If you were using the groups feature you will need to apply some changes:
Start by renaming the `./groups` folder to `./components` in your project root folder.
Make sure to do a database backup before your migration.
:::
Those migration are only necessary if you have data in production. Otherwise you should simply recreate your db.
To keep your preferences you can backup the `core_store` table data.
#### Bookshelf
Some database changes have occured:
- Component join tables have been renamed from `{content_type}_groups` to `{content_type}_components`.
- Component join tables column `group_type` is renamed to `component_type`.
- Component join tables column `group_id` is renamed to `component_id`.
**Migration queries**
Make sure to run those queries for the tables that exist in your database.
_`Queries for a Restaurant content type`_
:::: tabs
::: tab Sqlite
```sql
-- renaming the table
ALTER TABLE restaurants_groups
RENAME TO restaurants_components;
-- renaming the columns
ALTER TABLE restaurants_components
RENAME COLUMN group_type to component_type;
ALTER TABLE restaurants_components
RENAME COLUMN group_id to component_id;
```
:::
::: tab Postgres
```sql
-- renaming the table
ALTER TABLE restaurants_groups
RENAME TO restaurants_components;
-- renaming the columns
ALTER TABLE restaurants_components
RENAME COLUMN group_type to component_type;
ALTER TABLE restaurants_components
RENAME COLUMN group_id to component_id;
```
:::
::: tab Mysql
```sql
-- renaming the table
RENAME TABLE restaurants_groups TO restaurants_components;
-- renaming the columns
ALTER TABLE restaurants_components
RENAME COLUMN group_type to component_type;
ALTER TABLE restaurants_components
RENAME COLUMN group_id to component_id;
```
:::
::::
---
You might notice that you still have some tables containg the `group` keyword. Those are the tables that contain the groups data.
If you want to rename them you have 3 steps to follow:
**1. Rename the table in your DB (you can use the table renaming query shown above).**
:::: tabs
::: tab Sqlite
```sql
ALTER TABLE groups_old_table_name
RENAME TO components_new_table_name;
```
:::
::: tab Postgres
```sql
ALTER TABLE groups_old_table_name
RENAME TO components_new_table_name;
```
:::
::: tab Mysql
```sql
-- renaming the table
RENAME TABLE groups_old_table_name TO components_new_table_name;
```
:::
::::
**2. Change the `collectionName` of the component**
**Before**
`./api/components/category/component.json`
```json
{
"collectionName": "groups_old_table_name"
//...
}
```
**After**
`./api/components/category/component.json`
```json
{
"collectionName": "components_new_table_name"
//....
}
```
**3. Update the `component_type` values in the join tables**
_Repeat this query for every join table where you are using this component._
```sql
UPDATE restaurant_components
SET component_type = 'groups_old_table_name'
WHERE component_type = 'components_new_table_name';
```
#### Mongo
In `mongo` the relation between a content type and its components is held in an array of references. To know which component type it referes to, the array also contains a `kind` attribute containing the component Schema name.
**How to migrate**
**1. Get your new global ids**
The `kind` attribute references the Strapi `globalId` of a model. To get your component global ids run: