Skip to content

Commit 0a8ddca

Browse files
authored
[Chore] Change VARBINARY columns to VARCHAR (#78)
1 parent 135f656 commit 0a8ddca

24 files changed

Lines changed: 853 additions & 724 deletions

.env

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ APP_SECRET=630dc0d699fd37e720aff268f75583ed
2424
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
2525
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
2626
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11"
27-
# IMPORTANT: You MUST also configure your db driver and server_version in config/packages/doctrine.yaml
28-
DATABASE_URL=mysql://davis:davis@127.0.0.1:3306/davis
27+
DATABASE_URL="mysql://davis:davis@127.0.0.1:3306/davis?serverVersion=mariadb-10.6.10&charset=utf8mb4"
2928
###< doctrine/doctrine-bundle ###
3029

3130
###> symfony/mailer ###

README.md

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ Created and maintained (with the help of the community) by [@tchapi](https://git
3636
composer install
3737
```
3838

39-
2. At least put the correct credentials to your database in your `.env.local` file so you can easily create your database.
39+
2. At least put the correct credentials to your database in your `.env.local` file so you can easily create the necessary tables.
4040

41-
3. Create the database:
41+
3. Run the migrations to create all the necessary tables:
4242

4343
```
44-
bin/console doctrine:schema:create
44+
bin/console doctrine:migrations:migrate
4545
```
4646

47-
**Davis** can be used with a pre-existing MySQL database (_for instance, one previously managed by Baïkal_). The only missing table would be the `migrations` table, that you can recreate automatically when running the migrations.
47+
**Davis** can also be used with a pre-existing MySQL database (_for instance, one previously managed by Baïkal_). See the paragraph "Migrating from Baikal" for more info.
4848

49-
> The migrations are not _exactly_ equivalent to those of Baïkal, and allow for a bit more room in columns.
49+
> The tables are not _exactly_ equivalent to those of Baïkal, and allow for a bit more room in columns for instance (among other things)
5050
5151
## Configuration
5252

@@ -57,7 +57,7 @@ Create your own `.env.local` file to change the necessary variables, if you plan
5757
a. The database url (_you should already have it configured since you created the database previously_)
5858

5959
```
60-
DATABASE_URL=mysql://db_user:db_pass@host:3306/db_name
60+
DATABASE_URL=mysql://db_user:db_pass@host:3306/db_name?serverVersion=mariadb-10.6.10&charset=utf8mb4
6161
```
6262

6363
b. The admin password for the backend
@@ -123,21 +123,35 @@ LDAP_AUTH_USER_AUTOCREATE=true # false by default
123123
> LDAP_MAIL_ATTRIBUTE="zimbraMailDeliveryAddress"
124124
> ```
125125
126-
## Migrating from Baïkal ?
126+
## Migrating from Baïkal?
127127
128128
If you're migrating from Baïkal, then you will likely want to do the following :
129129
130130
1. Get a backup of your data (without the `CREATE` statements, but with complete `INSERT` statements):
131131
132-
`mysqldump -u root -p --no-create-info --complete-insert baikal > baikal_to_davis.sql # baikal is the actual name of your database`
132+
```
133+
mysqldump -u root -p --no-create-info --complete-insert baikal > baikal_to_davis.sql # baikal is the actual name of your database
134+
```
135+
133136
134-
2. Create a new database for Davis (let's name it `davis`) and create the schema :
137+
2. Create a new database for Davis (let's name it `davis`) and create the base schema:
138+
139+
```
140+
bin/console doctrine:migrations:migrate 'DoctrineMigrations\Version20191030113307' --no-interaction
141+
```
135142
136-
`bin/console doctrine:schema:create`
137143
138144
3. Reimport the data back:
139145
140-
`mysql -uroot -p davis < baikal_to_davis.sql`
146+
```
147+
mysql -uroot -p davis < baikal_to_davis.sql
148+
```
149+
150+
4. Run the necessary remaining migrations:
151+
152+
```
153+
bin/console doctrine:migrations:migrate
154+
```
141155
142156
# Access / Webserver
143157
@@ -196,7 +210,7 @@ The main endpoint for CalDAV, WebDAV or CardDAV is at `/dav`.
196210
# Env vars (if you did not use .env.local)
197211
SetEnv APP_ENV prod
198212
SetEnv APP_SECRET <app-secret-id>
199-
SetEnv DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name"
213+
SetEnv DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name?serverVersion=mariadb-10.6.10&charset=utf8mb4"
200214
# ... etc
201215
</VirtualHost>
202216
@@ -221,7 +235,7 @@ The main endpoint for CalDAV, WebDAV or CardDAV is at `/dav`.
221235
222236
# Env vars (if you did not use .env.local) fastcgi_param APP_ENV prod;
223237
fastcgi_param APP_SECRET <app-secret-id>;
224-
fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name";
238+
fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name?serverVersion=mariadb-10.6.10&charset=utf8mb4";
225239
# ... etc ...
226240
227241
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
@@ -275,9 +289,22 @@ You can start the containers with :
275289
276290
cd docker && docker-compose up -d
277291
278-
**⚠ Do not forget to create the database the first time you run the container** :
292+
**⚠ Do not forget to run all the migrations the first time you run the container** :
293+
294+
docker exec -it davis sh -c "APP_ENV=prod bin/console doctrine:migrations:migrate --no-interaction"
295+
296+
### Updating
297+
298+
If you update the code, you need to make sure the database structure is in sync.
299+
300+
**Before v3.0.0**, you need to force the update:
301+
302+
docker exec -it davis sh -c "APP_ENV=prod bin/console doctrine:schema:update --force --no-interaction"
303+
304+
**For v3.0.0 and after**, you can just migrate again (_provided you correctly followed the migration notes in the v3.0.0 release_):
305+
306+
docker exec -it davis sh -c "APP_ENV=prod bin/console doctrine:migrations:migrate --no-interaction"
279307
280-
docker exec -it davis sh -c "APP_ENV=prod bin/console doctrine:schema:create --no-interaction"
281308
282309
Then, head up to `http://<YOUR_DOCKER_IP>:9000` to see the status display :
283310

0 commit comments

Comments
 (0)