Update initial SQL to create usr_emails table.

I much prefer running patches to update the schema, but ah well.
This commit is contained in:
Andrew Ruthven 2021-02-26 00:04:51 +13:00
parent 6f1a20e1a2
commit 1977e9f283
2 changed files with 21 additions and 3 deletions

View File

@ -14,8 +14,10 @@ INSERT INTO principal_type (principal_type_id, principal_type_desc) VALUES( 2, '
INSERT INTO principal_type (principal_type_id, principal_type_desc) VALUES( 3, 'Group' );
-- Create the administrator record.
INSERT INTO usr ( user_no, active, email_ok, updated, username, password, fullname, email )
VALUES ( 1, TRUE, current_date, current_date, 'admin', '**nimda', 'DAViCal Administrator', 'calendars@example.net' );
INSERT INTO usr ( user_no, active, email_ok, updated, username, password, fullname )
VALUES ( 1, TRUE, current_date, current_date, 'admin', '**nimda', 'DAViCal Administrator' );
INSERT INTO usr_emails ( user_no, email )
VALUES ( 1, 'calendars@example.net' );
INSERT INTO principal ( principal_id, type_id, user_no, displayname, default_privileges )
VALUES ( 1, 1, 1, 'DAViCal Administrator', 0::BIT(24) );

View File

@ -439,6 +439,22 @@ CREATE TABLE calendar_attendee (
PRIMARY KEY ( dav_id, attendee )
);
CREATE TABLE usr_emails (
user_no INTEGER NOT NULL REFERENCES usr(user_no) ON UPDATE CASCADE ON DELETE CASCADE,
email VARCHAR,
main boolean DEFAULT true,
UNIQUE (email)
);
-- Ensure that a principal only has one primary email address.
CREATE UNIQUE INDEX usr_emails_primary
ON usr_emails
USING btree
(user_no)
WHERE main = true;
ALTER TABLE usr
DROP COLUMN email CASCADE;
CREATE or REPLACE FUNCTION real_path_exists( TEXT ) RETURNS BOOLEAN AS $$
DECLARE
@ -489,4 +505,4 @@ CREATE SEQUENCE metrics_count_delticket;
CREATE SEQUENCE metrics_count_bind;
CREATE SEQUENCE metrics_count_unknown;
SELECT new_db_revision(1,3,3, 'Marzec' );
SELECT new_db_revision(1,3,4, 'Kwiecie<C5><84>' );