Commit 083dd462 authored by BERJON Matthieu's avatar BERJON Matthieu
Browse files

Add of a uniqueness constraint on webapps field



I added a uniqueness constraint of the field docker_name in the table
webapps because two equivalent same names shouldn't exist in the
database.
I took the advantage of this change to update the file by removing too
many calls and cleaning the file.
Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <matthieu.berjon@inria.fr>
parent b8de776d
......@@ -13,10 +13,11 @@ CREATE TABLE dj_job_uploads AS SELECT * FROM job_uploads;
--
-- Modify the auth_user to fit Django's original table format
--
ALTER TABLE `auth_user` MODIFY COLUMN `email` VARCHAR(254) COLLATE utf8_bin NOT NULL;
ALTER TABLE `auth_user` CHANGE COLUMN `encrypted_password` `password` VARCHAR(128) COLLATE utf8_bin NOT NULL;
ALTER TABLE `auth_user` CHANGE COLUMN `created_at` `date_joined` datetime(6) NOT NULL;
ALTER TABLE `auth_user`
MODIFY COLUMN `email` VARCHAR(254) COLLATE utf8_bin NOT NULL,
CHANGE COLUMN `encrypted_password` `password` VARCHAR(128) COLLATE utf8_bin NOT NULL,
CHANGE COLUMN `created_at` `date_joined` datetime(6) NOT NULL,
DROP COLUMN `reset_password_token`,
DROP COLUMN `reset_password_sent_at`,
DROP COLUMN `remember_created_at`,
......@@ -31,8 +32,7 @@ ALTER TABLE `auth_user`
DROP COLUMN `confirmed_at`,
DROP COLUMN `confirmation_sent_at`,
DROP COLUMN `sshkey`,
DROP COLUMN `auth_token`;
ALTER TABLE `auth_user`
DROP COLUMN `auth_token`,
ADD `last_login` datetime(6) DEFAULT NULL,
ADD `is_superuser` tinyint(1) NOT NULL,
ADD `username` varchar(150) NOT NULL,
......@@ -44,7 +44,6 @@ UPDATE `auth_user` SET `username`=`email`;
ALTER TABLE `auth_user`
MODIFY `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT FIRST,
ADD UNIQUE KEY `username` (`username`);
-- ADD PRIMARY KEY AUTO_INCREMENT FIRST (`id`),
--
-- Create all other Django specific tables
......@@ -62,9 +61,7 @@ CREATE TABLE `django_content_type` (
ALTER TABLE `django_content_type`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `django_content_type_app_label_model_76bd3d3b_uniq` (`app_label`,`model`);
ALTER TABLE `django_content_type`
ADD UNIQUE KEY `django_content_type_app_label_model_76bd3d3b_uniq` (`app_label`,`model`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
......@@ -79,9 +76,7 @@ CREATE TABLE `django_migrations` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `django_migrations`
ADD PRIMARY KEY (`id`);
ALTER TABLE `django_migrations`
ADD PRIMARY KEY (`id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
......@@ -102,12 +97,8 @@ CREATE TABLE `django_admin_log` (
ALTER TABLE `django_admin_log`
ADD PRIMARY KEY (`id`),
ADD KEY `django_admin_log_content_type_id_c4bce8eb_fk_django_co` (`content_type_id`),
ADD KEY `django_admin_log_user_id_c564eba6_fk_auth_user_id` (`user_id`);
ALTER TABLE `django_admin_log`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `django_admin_log`
ADD KEY `django_admin_log_user_id_c564eba6_fk_auth_user_id` (`user_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `django_admin_log_content_type_id_c4bce8eb_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`),
ADD CONSTRAINT `django_admin_log_user_id_c564eba6_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
......@@ -135,18 +126,12 @@ CREATE TABLE `django_site` (
`name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `django_site`
--
INSERT INTO `django_site` (`id`, `domain`, `name`) VALUES
(1, 'allgo.inria.fr', 'allgo.inria.fr');
ALTER TABLE `django_site`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `django_site_domain_a2e37b91_uniq` (`domain`);
ALTER TABLE `django_site`
ADD UNIQUE KEY `django_site_domain_a2e37b91_uniq` (`domain`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
......@@ -160,9 +145,7 @@ CREATE TABLE `auth_group` (
ALTER TABLE `auth_group`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`);
ALTER TABLE `auth_group`
ADD UNIQUE KEY `name` (`name`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
......@@ -181,9 +164,7 @@ ALTER TABLE `auth_permission`
ADD UNIQUE KEY `auth_permission_content_type_id_codename_01ab375a_uniq` (`content_type_id`,`codename`);
ALTER TABLE `auth_permission`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `auth_permission`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `auth_permission_content_type_id_2f476e4b_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`);
--
......@@ -199,12 +180,8 @@ CREATE TABLE `auth_group_permissions` (
ALTER TABLE `auth_group_permissions`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `auth_group_permissions_group_id_permission_id_0cd325b0_uniq` (`group_id`,`permission_id`),
ADD KEY `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm` (`permission_id`);
ALTER TABLE `auth_group_permissions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `auth_group_permissions`
ADD KEY `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm` (`permission_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`),
ADD CONSTRAINT `auth_group_permissions_group_id_b120cbf9_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`);
......@@ -221,12 +198,8 @@ CREATE TABLE `auth_user_groups` (
ALTER TABLE `auth_user_groups`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `auth_user_groups_user_id_group_id_94350c0c_uniq` (`user_id`,`group_id`),
ADD KEY `auth_user_groups_group_id_97559544_fk_auth_group_id` (`group_id`);
ALTER TABLE `auth_user_groups`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `auth_user_groups`
ADD KEY `auth_user_groups_group_id_97559544_fk_auth_group_id` (`group_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `auth_user_groups_group_id_97559544_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`),
ADD CONSTRAINT `auth_user_groups_user_id_6a12ed8b_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
......@@ -243,12 +216,8 @@ CREATE TABLE `auth_user_user_permissions` (
ALTER TABLE `auth_user_user_permissions`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `auth_user_user_permissions_user_id_permission_id_14a6b632_uniq` (`user_id`,`permission_id`),
ADD KEY `auth_user_user_permi_permission_id_1fbb5f2c_fk_auth_perm` (`permission_id`);
ALTER TABLE `auth_user_user_permissions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `auth_user_user_permissions`
ADD KEY `auth_user_user_permi_permission_id_1fbb5f2c_fk_auth_perm` (`permission_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `auth_user_user_permi_permission_id_1fbb5f2c_fk_auth_perm` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`),
ADD CONSTRAINT `auth_user_user_permissions_user_id_a95ead1b_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
......@@ -277,8 +246,7 @@ ALTER TABLE `dj_users`
DROP COLUMN `auth_token`;
UPDATE `dj_users` SET `user_id`=`id`;
ALTER TABLE `dj_users`
ADD UNIQUE KEY `user_id` (`user_id`);
ALTER TABLE `dj_users`
ADD UNIQUE KEY `user_id` (`user_id`),
ADD CONSTRAINT `dj_users_users_id_aa366e15_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
--
......@@ -286,8 +254,9 @@ ALTER TABLE `dj_users`
--
ALTER TABLE `dj_webapps`
DROP COLUMN `private`;
ALTER TABLE `dj_webapps` CHANGE COLUMN `default_job_queue_id` `job_queue_id` int(11) NOT NULL;
DROP COLUMN `private`,
CHANGE COLUMN `default_job_queue_id` `job_queue_id` int(11) NOT NULL,
ADD UNIQUE (docker_name);
--
-- Update of jobs table
......@@ -319,9 +288,7 @@ CREATE TABLE `socialaccount_socialapp` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `socialaccount_socialapp`
ADD PRIMARY KEY (`id`);
ALTER TABLE `socialaccount_socialapp`
ADD PRIMARY KEY (`id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
......@@ -341,12 +308,8 @@ CREATE TABLE `socialaccount_socialaccount` (
ALTER TABLE `socialaccount_socialaccount`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `socialaccount_socialaccount_provider_uid_fc810c6e_uniq` (`provider`,`uid`),
ADD KEY `socialaccount_socialaccount_user_id_8146e70c_fk_auth_user_id` (`user_id`);
ALTER TABLE `socialaccount_socialaccount`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `socialaccount_socialaccount`
ADD KEY `socialaccount_socialaccount_user_id_8146e70c_fk_auth_user_id` (`user_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `socialaccount_socialaccount_user_id_8146e70c_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
--
......@@ -362,12 +325,8 @@ CREATE TABLE `socialaccount_socialapp_sites` (
ALTER TABLE `socialaccount_socialapp_sites`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `socialaccount_socialapp_sites_socialapp_id_site_id_71a9a768_uniq` (`socialapp_id`,`site_id`),
ADD KEY `socialaccount_socialapp_sites_site_id_2579dee5_fk_django_site_id` (`site_id`);
ALTER TABLE `socialaccount_socialapp_sites`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `socialaccount_socialapp_sites`
ADD KEY `socialaccount_socialapp_sites_site_id_2579dee5_fk_django_site_id` (`site_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `socialaccount_social_socialapp_id_97fb6e7d_fk_socialacc` FOREIGN KEY (`socialapp_id`) REFERENCES `socialaccount_socialapp` (`id`),
ADD CONSTRAINT `socialaccount_socialapp_sites_site_id_2579dee5_fk_django_site_id` FOREIGN KEY (`site_id`) REFERENCES `django_site` (`id`);
......@@ -387,12 +346,8 @@ CREATE TABLE `socialaccount_socialtoken` (
ALTER TABLE `socialaccount_socialtoken`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `socialaccount_socialtoken_app_id_account_id_fca4e0ac_uniq` (`app_id`,`account_id`),
ADD KEY `socialaccount_social_account_id_951f210e_fk_socialacc` (`account_id`);
ALTER TABLE `socialaccount_socialtoken`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `socialaccount_socialtoken`
ADD KEY `socialaccount_social_account_id_951f210e_fk_socialacc` (`account_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `socialaccount_social_account_id_951f210e_fk_socialacc` FOREIGN KEY (`account_id`) REFERENCES `socialaccount_socialaccount` (`id`),
ADD CONSTRAINT `socialaccount_social_app_id_636a42d7_fk_socialacc` FOREIGN KEY (`app_id`) REFERENCES `socialaccount_socialapp` (`id`);
......@@ -411,12 +366,8 @@ CREATE TABLE `account_emailaddress` (
ALTER TABLE `account_emailaddress`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`),
ADD KEY `account_emailaddress_user_id_2c513194_fk_auth_user_id` (`user_id`);
ALTER TABLE `account_emailaddress`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `account_emailaddress`
ADD KEY `account_emailaddress_user_id_2c513194_fk_auth_user_id` (`user_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `account_emailaddress_user_id_2c513194_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
--
......@@ -434,12 +385,8 @@ CREATE TABLE `account_emailconfirmation` (
ALTER TABLE `account_emailconfirmation`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `key` (`key`),
ADD KEY `account_emailconfirm_email_address_id_5b7f8c58_fk_account_e` (`email_address_id`);
ALTER TABLE `account_emailconfirmation`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `account_emailconfirmation`
ADD KEY `account_emailconfirm_email_address_id_5b7f8c58_fk_account_e` (`email_address_id`),
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
ADD CONSTRAINT `account_emailconfirm_email_address_id_5b7f8c58_fk_account_e` FOREIGN KEY (`email_address_id`) REFERENCES `account_emailaddress` (`id`);
COMMIT;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment