49 | | We've renamed a bunch of the core Django tables. To upgrade in MySQL and SQLite, execute this SQL in your database: |
| 49 | We've renamed a bunch of the core Django tables. Due to functionality differences between the various database backends, the SQL to perform the necessary tasks varies slightly between engines. |
| 50 | |
| 51 | To upgrade in SQLite, execute this SQL in your database (some steps are more involved because SQLite has only limited ALTER TABLE functionality. We have to instead create working tables, move the data, and then replace the old tables with the new ones: |
| 52 | |
| 53 | {{{ |
| 54 | ALTER TABLE auth_groups RENAME TO auth_group; |
| 55 | ALTER TABLE auth_groups_permissions RENAME TO auth_group_permissions; |
| 56 | ALTER TABLE auth_messages RENAME TO auth_message; |
| 57 | ALTER TABLE auth_permissions RENAME TO auth_permission; |
| 58 | ALTER TABLE auth_users RENAME TO auth_user; |
| 59 | ALTER TABLE auth_users_groups RENAME TO auth_user_groups; |
| 60 | ALTER TABLE auth_users_user_permissions RENAME TO auth_user_user_permissions; |
| 61 | ALTER TABLE content_types RENAME TO django_content_type; |
| 62 | ALTER TABLE core_sessions RENAME TO django_session; |
| 63 | ALTER TABLE django_flatpages RENAME TO django_flatpage; |
| 64 | ALTER TABLE django_flatpages_sites RENAME TO django_flatpage_sites; |
| 65 | ALTER TABLE django_redirects RENAME TO django_redirect; |
| 66 | ALTER TABLE sites RENAME TO django_site; |
| 67 | |
| 68 | CREATE TABLE "django_content_type_new" ( |
| 69 | "id" integer NOT NULL PRIMARY KEY, |
| 70 | "name" varchar(100) NOT NULL, |
| 71 | "app_label" varchar(100) NOT NULL, |
| 72 | "model" varchar(100) NOT NULL, |
| 73 | UNIQUE ("app_label", "model") |
| 74 | ); |
| 75 | |
| 76 | INSERT INTO django_content_type_new |
| 77 | (id,name,app_label,model) |
| 78 | SELECT id,name,package,python_module_name |
| 79 | FROM django_content_type; |
| 80 | |
| 81 | |
| 82 | ALTER TABLE django_content_type rename to django_content_type_old; |
| 83 | ALTER TABLE django_content_type_new rename to django_content_type; |
| 84 | |
| 85 | DROP TABLE django_content_type_old; |
| 86 | |
| 87 | DROP TABLE packages; |
| 88 | |
| 89 | |
| 90 | ALTER TABLE auth_permission ADD COLUMN content_type_id INTEGER; |
| 91 | }}} |
| 92 | |
| 93 | To upgrade in MySQL , execute this SQL in your database: |