summaryrefslogtreecommitdiff
path: root/rt/etc/upgrade/4.1.1/schema.Pg
blob: 91ba5a68846d13bab80f355523d5f6524d720f1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
DROP TABLE IF EXISTS ObjectScrips;
DROP SEQUENCE IF EXISTS objectscrips_id_seq;

CREATE SEQUENCE objectscrips_id_seq;
CREATE TABLE ObjectScrips (
  id INTEGER DEFAULT nextval('objectscrips_id_seq'),
  Scrip integer NOT NULL,
  Stage varchar(32) NOT NULL DEFAULT 'TransactionCreate' ,
  ObjectId integer NOT NULL,
  SortOrder integer NOT NULL DEFAULT 0  ,

  Creator integer NOT NULL DEFAULT 0  ,
  Created TIMESTAMP NULL  ,
  LastUpdatedBy integer NOT NULL DEFAULT 0  ,
  LastUpdated TIMESTAMP NULL  ,
  PRIMARY KEY (id)

);
ALTER TABLE Scrips ADD COLUMN Disabled int2 NOT NULL DEFAULT 0;

INSERT INTO ObjectScrips(
    Scrip, Stage, ObjectId,
    Creator, Created, LastUpdatedBy, LastUpdated
)
SELECT id, Stage, Queue, Creator, Created, LastUpdatedBy, LastUpdated
FROM Scrips
;

UPDATE Scrips SET Disabled = 1 WHERE Stage = 'Disabled';
UPDATE ObjectScrips SET Stage = 'TransactionCreate' WHERE Stage = 'Disabled';

CREATE UNIQUE INDEX ObjectScrips1 ON ObjectScrips (ObjectId, Scrip);

ALTER TABLE Scrips
    DROP COLUMN Stage,
    DROP COLUMN Queue;