~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to userdb/migrations/20090406-01.sql

  • Committer: mattgiuca
  • Date: 2008-03-07 15:12:02 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:669
Timestamps are now stored within the program as Python "time" module's
    "struct_time" objects, rather than strings directly from the DB.
    They are parsed into struct_time objects when reading from the db.
    They are formatted into SQL Timestamp strings when writing to the db.
    This allows them to be manipulated and compared within the program.

common.db: _escape now accepts struct_time objects - it formats them into SQL
            time strings.
common.user: The User constructor now parses "acct_exp", "pass_exp" and
            "last_login" fields as timestamp strings, and stores them
            internally as struct_time.
tutorialservice: When recording a submission, the "date" field is now stored
            as a struct_time, not a formatted string.
login.py: When logging in, uncommented call to write last_login to the DB,
            passing the current local time. (This now works correctly).
            Note that this is done after retrieving the user details, so the
            value of last_login stored in the session is the _old_ last login,
            not the new one (this is intentional).

(With Tom Conway).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
BEGIN;
2
 
 
3
 
ALTER TABLE project_set ALTER COLUMN max_students_per_group DROP NOT NULL;
4
 
ALTER TABLE project_set ALTER COLUMN max_students_per_group DROP DEFAULT;
5
 
 
6
 
ALTER TABLE project ALTER COLUMN synopsis TYPE TEXT;
7
 
ALTER TABLE project ALTER COLUMN url TYPE TEXT;
8
 
ALTER TABLE project ADD COLUMN short_name TEXT NOT NULL;
9
 
ALTER TABLE project ADD COLUMN name TEXT NOT NULL;
10
 
 
11
 
CREATE OR REPLACE FUNCTION check_project_namespacing_insertupdate()
12
 
RETURNS trigger AS '
13
 
    DECLARE
14
 
        oid INTEGER;
15
 
    BEGIN
16
 
        IF TG_OP = ''UPDATE'' THEN
17
 
            IF NEW.projectsetid = OLD.projectsetid AND NEW.short_name = OLD.short_name THEN
18
 
                RETURN NEW;
19
 
            END IF;
20
 
        END IF;
21
 
        SELECT offeringid INTO oid FROM project_set WHERE project_set.projectsetid = NEW.projectsetid;
22
 
        PERFORM 1 FROM project, project_set
23
 
        WHERE project_set.offeringid = oid AND
24
 
              project.projectsetid = project_set.projectsetid AND
25
 
              project.short_name = NEW.short_name;
26
 
        IF found THEN
27
 
            RAISE EXCEPTION ''a project named % already exists in offering ID %'', NEW.short_name, oid;
28
 
        END IF;
29
 
        RETURN NEW;
30
 
    END;
31
 
' LANGUAGE 'plpgsql';
32
 
 
33
 
CREATE TRIGGER check_project_namespacing
34
 
    BEFORE INSERT OR UPDATE ON project
35
 
    FOR EACH ROW EXECUTE PROCEDURE check_project_namespacing_insertupdate();
36
 
 
37
 
ALTER TABLE project_extension ADD COLUMN extensionid SERIAL PRIMARY KEY;
38
 
 
39
 
ALTER TABLE project_submission ADD COLUMN submissionid SERIAL PRIMARY KEY;
40
 
ALTER TABLE project_submission ADD COLUMN date_submitted TIMESTAMP NOT NULL;
41
 
ALTER TABLE project_submission ADD COLUMN submitter INT4 REFERENCES login (loginid) NOT NULL;
42
 
 
43
 
COMMIT;