diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-08-18 18:19:10 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-08-18 18:19:10 +0200 |
commit | 8f4be835329b7d2c78c8f55b8ecbf622040ccce9 (patch) | |
tree | 4cbbab9372c288331e10adf5c3be30e74edaf1e4 /migrations | |
parent | 28c046e169c5874ce066228e7f3658d02317c216 (diff) |
Book Marx: Apply role-based access scheme.
Diffstat (limited to 'migrations')
-rw-r--r-- | migrations/7_migrate_bookmarx_to_role_access_model.sql | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/migrations/7_migrate_bookmarx_to_role_access_model.sql b/migrations/7_migrate_bookmarx_to_role_access_model.sql new file mode 100644 index 0000000..574a07c --- /dev/null +++ b/migrations/7_migrate_bookmarx_to_role_access_model.sql @@ -0,0 +1,24 @@ +BEGIN TRANSACTION; + +ALTER TABLE post_targets DROP CONSTRAINT lazychat_targets_message_fkey; +ALTER TABLE lazychat_references DROP CONSTRAINT lazychat_references_referee_fkey; + +INSERT INTO post_targets + SELECT bm.id, rt.role + FROM bookmarks bm + INNER JOIN role_tags rt ON tag = 'world' + WHERE visibility = 'public'; +INSERT INTO post_targets + SELECT bm.id, udt.target + FROM bookmarks bm + INNER JOIN user_default_target udt ON bm.owner = udt."user" + WHERE visibility = 'protected'; + +ALTER TABLE bookmarks DROP COLUMN visibility; + +CREATE VIEW user_visible_bookmarks AS + SELECT uvp.user, uvp.message + FROM user_visible_posts uvp + INNER JOIN bookmarks bm ON bm.id = uvp.message; + +COMMIT; |