summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sql/grant-all.mysql.sql5
-rw-r--r--lib/sql/grant-all.postgres.sql9
-rw-r--r--lib/sql/migration/008-confirmations.sql11
-rw-r--r--lib/sql/migration/009-drop-registrationprofile.sql27
-rw-r--r--lib/sql/migration/010-optout-tables.sql5
-rw-r--r--lib/sql/migration/011-patch-change-notifications.sql12
6 files changed, 63 insertions, 6 deletions
diff --git a/lib/sql/grant-all.mysql.sql b/lib/sql/grant-all.mysql.sql
index 4dd6efb..1bff526 100644
--- a/lib/sql/grant-all.mysql.sql
+++ b/lib/sql/grant-all.mysql.sql
@@ -12,7 +12,7 @@ GRANT SELECT, UPDATE, INSERT, DELETE ON auth_user_groups TO 'www-data'@localhost
GRANT SELECT, UPDATE, INSERT, DELETE ON auth_group TO 'www-data'@localhost;
GRANT SELECT, UPDATE, INSERT, DELETE ON auth_user_user_permissions TO 'www-data'@localhost;
GRANT SELECT, UPDATE, INSERT, DELETE ON auth_permission TO 'www-data'@localhost;
-GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_userpersonconfirmation TO 'www-data'@localhost;
+GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_emailconfirmation TO 'www-data'@localhost;
GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_state TO 'www-data'@localhost;
GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_comment TO 'www-data'@localhost;
GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_person TO 'www-data'@localhost;
@@ -22,7 +22,8 @@ GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_project TO 'www-data'@localhos
GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_bundle TO 'www-data'@localhost;
GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_bundle_patches TO 'www-data'@localhost;
GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_patch TO 'www-data'@localhost;
-GRANT SELECT, UPDATE, INSERT, DELETE ON registration_registrationprofile TO 'www-data'@localhost;
+GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_emailoptout TO 'www-data'@localhost;
+GRANT SELECT, UPDATE, INSERT, DELETE ON patchwork_patchchangenotification TO 'www-data'@localhost;
-- allow the mail user (in this case, 'nobody') to add patches
GRANT INSERT, SELECT ON patchwork_patch TO 'nobody'@localhost;
diff --git a/lib/sql/grant-all.postgres.sql b/lib/sql/grant-all.postgres.sql
index 6a1a47d..72abb57 100644
--- a/lib/sql/grant-all.postgres.sql
+++ b/lib/sql/grant-all.postgres.sql
@@ -13,7 +13,7 @@ GRANT SELECT, UPDATE, INSERT, DELETE ON
auth_group,
auth_user_user_permissions,
auth_permission,
- patchwork_userpersonconfirmation,
+ patchwork_emailconfirmation,
patchwork_state,
patchwork_comment,
patchwork_person,
@@ -23,7 +23,8 @@ GRANT SELECT, UPDATE, INSERT, DELETE ON
patchwork_bundle,
patchwork_bundlepatch,
patchwork_patch,
- registration_registrationprofile
+ patchwork_emailoptout,
+ patchwork_patchchangenotification
TO "www-data";
GRANT SELECT, UPDATE ON
auth_group_id_seq,
@@ -43,10 +44,10 @@ GRANT SELECT, UPDATE ON
patchwork_person_id_seq,
patchwork_project_id_seq,
patchwork_state_id_seq,
- patchwork_userpersonconfirmation_id_seq,
+ patchwork_emailconfirmation_id_seq,
patchwork_userprofile_id_seq,
patchwork_userprofile_maintainer_projects_id_seq,
- registration_registrationprofile_id_seq
+ patchwork_patchchangenotification_id_seq
TO "www-data";
-- allow the mail user (in this case, 'nobody') to add patches
diff --git a/lib/sql/migration/008-confirmations.sql b/lib/sql/migration/008-confirmations.sql
new file mode 100644
index 0000000..89437a2
--- /dev/null
+++ b/lib/sql/migration/008-confirmations.sql
@@ -0,0 +1,11 @@
+BEGIN;
+ALTER TABLE "patchwork_userpersonconfirmation"
+ RENAME TO "patchwork_emailconfirmation";
+ALTER SEQUENCE "patchwork_userpersonconfirmation_id_seq"
+ RENAME TO "patchwork_emailconfirmation_id_seq";
+ALTER TABLE "patchwork_emailconfirmation"
+ ALTER COLUMN "user_id" DROP NOT NULL,
+ ADD COLUMN "type" varchar(20) NOT NULL DEFAULT 'userperson';
+ALTER TABLE "patchwork_emailconfirmation"
+ ALTER COLUMN "type" DROP DEFAULT;
+COMMIT;
diff --git a/lib/sql/migration/009-drop-registrationprofile.sql b/lib/sql/migration/009-drop-registrationprofile.sql
new file mode 100644
index 0000000..f1c2b43
--- /dev/null
+++ b/lib/sql/migration/009-drop-registrationprofile.sql
@@ -0,0 +1,27 @@
+BEGIN;
+
+DELETE FROM registration_registrationprofile;
+
+-- unlink users who have contributed
+
+UPDATE patchwork_person SET user_id = NULL
+ WHERE user_id IN (SELECT id FROM auth_user WHERE is_active = False)
+ AND id IN (SELECT DISTINCT submitter_id FROM patchwork_comment);
+
+-- remove persons who only have a user linkage
+
+DELETE FROM patchwork_person WHERE user_id IN
+ (SELECT id FROM auth_user WHERE is_active = False);
+
+-- delete profiles
+
+DELETE FROM patchwork_userprofile WHERE user_id IN
+ (SELECT id FROM auth_user WHERE is_active = False);
+
+-- delete inactive users
+
+DELETE FROM auth_user WHERE is_active = False;
+
+DROP TABLE registration_registrationprofile;
+
+COMMIT;
diff --git a/lib/sql/migration/010-optout-tables.sql b/lib/sql/migration/010-optout-tables.sql
new file mode 100644
index 0000000..0a5d835
--- /dev/null
+++ b/lib/sql/migration/010-optout-tables.sql
@@ -0,0 +1,5 @@
+BEGIN;
+CREATE TABLE "patchwork_emailoptout" (
+ "email" varchar(200) NOT NULL PRIMARY KEY
+);
+COMMIT;
diff --git a/lib/sql/migration/011-patch-change-notifications.sql b/lib/sql/migration/011-patch-change-notifications.sql
new file mode 100644
index 0000000..0a9b9b7
--- /dev/null
+++ b/lib/sql/migration/011-patch-change-notifications.sql
@@ -0,0 +1,12 @@
+BEGIN;
+CREATE TABLE "patchwork_patchchangenotification" (
+ "patch_id" integer NOT NULL PRIMARY KEY REFERENCES "patchwork_patch" ("id") DEFERRABLE INITIALLY DEFERRED,
+ "last_modified" timestamp with time zone NOT NULL,
+ "orig_state_id" integer NOT NULL REFERENCES "patchwork_state" ("id") DEFERRABLE INITIALLY DEFERRED
+)
+;
+ALTER TABLE "patchwork_project" ADD COLUMN
+ "send_notifications" boolean NOT NULL DEFAULT False;
+ALTER TABLE "patchwork_project" ALTER COLUMN
+ "send_notifications" DROP DEFAULT;
+COMMIT;