Skip to content

Adding a new Table through Django Migrations

Additional steps need to be taken when adding a new table.

Steps

As per steps taken on 18th Jan 2022 to add a compliance table, though it was run before this.

Adviseable to run locally before testing on live servers.

1.) add these two lines to the top of the migration file

from django.conf import settings
dbname = settings.DATABASES['default']['NAME']

2.) add this single line migrations.RunSQL('alter database %s character set utf8' % dbname) at the top of the operations section like so:

    operations = [
+        migrations.RunSQL('alter database `%s` character set utf8' % dbname),
         migrations.CreateModel(
             name='OrganiserReport_2022',
             fields=[