# HG changeset patch # User jbe # Date 1460829636 -7200 # Node ID bca63fc70e73521059f0d95b14caded7d0de788c # Parent 61fab72168930119b23d23a08637fbf384d9221b Drop and re-create view "expired_session" in update script to v3.2.0 (necessary to alter column type in table "session") diff -r 61fab7216893 -r bca63fc70e73 update/core-update.v3.1.0-v3.2.0.sql --- a/update/core-update.v3.1.0-v3.2.0.sql Sat Apr 16 19:57:53 2016 +0200 +++ b/update/core-update.v3.1.0-v3.2.0.sql Sat Apr 16 20:00:36 2016 +0200 @@ -31,8 +31,19 @@ COMMENT ON COLUMN "member"."notification_sent" IS 'Timestamp of last scheduled notification mail that has been sent out'; ALTER TABLE "rendered_member_statement" ALTER COLUMN "member_id" SET DATA TYPE INT4; + +DROP VIEW "expired_session"; + ALTER TABLE "session" ALTER COLUMN "member_id" SET DATA TYPE INT4; +CREATE VIEW "expired_session" AS + SELECT * FROM "session" WHERE now() > "expiry"; +CREATE RULE "delete" AS ON DELETE TO "expired_session" DO INSTEAD + DELETE FROM "session" WHERE "ident" = OLD."ident"; + +COMMENT ON VIEW "expired_session" IS 'View containing all expired sessions where DELETE is possible'; +COMMENT ON RULE "delete" ON "expired_session" IS 'Rule allowing DELETE on rows in "expired_session" view, i.e. DELETE FROM "expired_session"'; + CREATE TABLE "subscription" ( PRIMARY KEY ("member_id", "unit_id"), "member_id" INT4 REFERENCES "member" ("id") ON DELETE CASCADE ON UPDATE CASCADE,