Skip to content

Commit

Permalink
Switching charset to utf8mb4
Browse files Browse the repository at this point in the history
  • Loading branch information
guilbaults committed Oct 16, 2024
1 parent 465d243 commit 2f9e3f5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
13 changes: 12 additions & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ Before installing in production, [a test environment should be set up to test th
The portal can be installed directly on a Rocky8 Apache web server or with Nginx and Gunicorn. The portal can also be deployed as a container with Podman or Kubernetes. Some scripts used to deploy both Nginx and Django containers inside the same pod are provided in the `podman` directory.
The various recommendations for any normal Django production deployment can be followed.

[Deploying Django](https://docs.djangoproject.com/en/3.2/howto/deployment/)
[Deploying Django](https://docs.djangoproject.com/en/5.0/howto/deployment/)

The database should support UTF8. With MariaDB, the default collation can be changed with the following command:

```
ALTER DATABASE userportal CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
```

Migration scripts will also ensure that the tables and columns are converted to the correct collation.

# Production with containers
Using containers is the recommended way to deploy the portal. The container is automatically built in the CI pipeline and pushed to the Github registry. This container is handling the django application. The static files are served by a standard Nginx container. Both containers are deployed in the same pod with a shared volume containing the static files.

# Production without containers on Rocky Linux 8

Expand Down
15 changes: 15 additions & 0 deletions jobstats/migrations/0002_utf8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Django 5.0.7 on 2024-10-16 18:38

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('jobstats', '0001_initial'),
]

operations = [
migrations.RunSQL('ALTER TABLE jobstats_jobscript CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'),
migrations.RunSQL('ALTER TABLE jobstats_jobscript MODIFY submit_script LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'),
]
16 changes: 16 additions & 0 deletions notes/migrations/0002_utf8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 5.0.7 on 2024-10-16 18:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('notes', '0001_initial'),
]

operations = [
migrations.RunSQL('ALTER TABLE notes_note CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'),
migrations.RunSQL('ALTER TABLE notes_note MODIFY title VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'),
migrations.RunSQL('ALTER TABLE notes_note MODIFY notes LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'),
]
4 changes: 3 additions & 1 deletion userportal/settings/20-databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
'HOST': 'dbserver',
'PORT': '3128',
'OPTIONS': {
}
'charset': 'utf8mb4',
'use_unicode': True,
},
},
'slurm': {
'ENGINE': 'django.db.backends.mysql',
Expand Down

0 comments on commit 2f9e3f5

Please sign in to comment.