diff options
Diffstat (limited to 'rt/etc/upgrade/4.1.1')
-rw-r--r-- | rt/etc/upgrade/4.1.1/acl.Pg | 31 | ||||
-rw-r--r-- | rt/etc/upgrade/4.1.1/content | 36 | ||||
-rw-r--r-- | rt/etc/upgrade/4.1.1/schema.Oracle | 29 | ||||
-rw-r--r-- | rt/etc/upgrade/4.1.1/schema.Pg | 36 | ||||
-rw-r--r-- | rt/etc/upgrade/4.1.1/schema.SQLite | 31 | ||||
-rw-r--r-- | rt/etc/upgrade/4.1.1/schema.mysql | 32 |
6 files changed, 195 insertions, 0 deletions
diff --git a/rt/etc/upgrade/4.1.1/acl.Pg b/rt/etc/upgrade/4.1.1/acl.Pg new file mode 100644 index 000000000..9e8fc0af0 --- /dev/null +++ b/rt/etc/upgrade/4.1.1/acl.Pg @@ -0,0 +1,31 @@ + +sub acl { + my $dbh = shift; + + my @acls; + + my @tables = qw ( + objectscrips_id_seq + ObjectScrips + ); + + my $db_user = RT->Config->Get('DatabaseUser'); + + my $sequence_right + = ( $dbh->{pg_server_version} >= 80200 ) + ? "USAGE, SELECT, UPDATE" + : "SELECT, UPDATE"; + + foreach my $table (@tables) { + # Tables are upper-case, sequences are lowercase in @tables + if ( $table =~ /^[a-z]/ ) { + push @acls, "GRANT $sequence_right ON $table TO \"$db_user\";" + } + else { + push @acls, "GRANT SELECT, INSERT, UPDATE, DELETE ON $table TO \"$db_user\";" + } + } + return (@acls); +} + +1; diff --git a/rt/etc/upgrade/4.1.1/content b/rt/etc/upgrade/4.1.1/content new file mode 100644 index 000000000..f3580bdc0 --- /dev/null +++ b/rt/etc/upgrade/4.1.1/content @@ -0,0 +1,36 @@ +use strict; +use warnings; + +our @Initial = ( + sub { + require RT::ObjectScrips; + foreach my $stage ('TransactionCreate', 'TransactionBatch') { + my $applications = RT::ObjectScrips->new( RT->SystemUser ); + $applications->Limit( FIELD => 'Stage', VALUE => $stage ); + my $alias = $applications->Join( + FIELD1 => 'Scrip', + TABLE2 => 'Scrips', FIELD2 => 'id' + ); + $applications->OrderByCols( + { ALIAS => $alias, FIELD => 'Description', ORDER => 'ASC' }, + ); + my %h; my $top_so = $h{0} = 0; + while ( my $record = $applications->Next ) { + my $oid = $record->ObjectId || 0; + + my $so; + unless ( $oid ) { + %h = (); $h{0} = $so = ++$top_so; + } + else { + $so = $h{ $oid } = ($h{$oid}||$h{0}) + 1; + } + next if $record->SortOrder == $so; + + my ($status, $msg) = $record->SetSortOrder($so); + RT->Logger->error("Couldn't set sort order: $msg") + unless $status; + } + } + }, +); diff --git a/rt/etc/upgrade/4.1.1/schema.Oracle b/rt/etc/upgrade/4.1.1/schema.Oracle new file mode 100644 index 000000000..33ea73806 --- /dev/null +++ b/rt/etc/upgrade/4.1.1/schema.Oracle @@ -0,0 +1,29 @@ +CREATE SEQUENCE OBJECTSCRIPS_seq; +CREATE TABLE ObjectScrips ( + id NUMBER(11,0) + CONSTRAINT ObjectScrips_Key PRIMARY KEY, + Scrip NUMBER(11,0) NOT NULL, + Stage VARCHAR2(32) DEFAULT 'TransactionCreate' NOT NULL, + ObjectId NUMBER(11,0) NOT NULL, + SortOrder NUMBER(11,0) DEFAULT 0 NOT NULL, + Creator NUMBER(11,0) DEFAULT 0 NOT NULL, + Created DATE, + LastUpdatedBy NUMBER(11,0) DEFAULT 0 NOT NULL, + LastUpdated DATE +); +ALTER TABLE Scrips ADD Disabled NUMBER(11,0) DEFAULT 0 NOT NULL; + +INSERT INTO ObjectScrips( + id, Scrip, Stage, ObjectId, + Creator, Created, LastUpdatedBy, LastUpdated +) +(SELECT OBJECTSCRIPS_seq.nextval, 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( Stage, Queue ); diff --git a/rt/etc/upgrade/4.1.1/schema.Pg b/rt/etc/upgrade/4.1.1/schema.Pg new file mode 100644 index 000000000..91ba5a688 --- /dev/null +++ b/rt/etc/upgrade/4.1.1/schema.Pg @@ -0,0 +1,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; diff --git a/rt/etc/upgrade/4.1.1/schema.SQLite b/rt/etc/upgrade/4.1.1/schema.SQLite new file mode 100644 index 000000000..2a6a2c4a4 --- /dev/null +++ b/rt/etc/upgrade/4.1.1/schema.SQLite @@ -0,0 +1,31 @@ +DROP TABLE IF EXISTS ObjectScrips; +CREATE TABLE ObjectScrips ( + id INTEGER NOT NULL , + Scrip int 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 DATETIME NULL , + LastUpdatedBy integer NOT NULL DEFAULT 0 , + LastUpdated DATETIME 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); + +# TODO: ALTER TABLE Scrips DROP COLUMN Stage; +# TODO: ALTER TABLE Scrips DROP COLUMN Queue; diff --git a/rt/etc/upgrade/4.1.1/schema.mysql b/rt/etc/upgrade/4.1.1/schema.mysql new file mode 100644 index 000000000..82f3f8452 --- /dev/null +++ b/rt/etc/upgrade/4.1.1/schema.mysql @@ -0,0 +1,32 @@ +DROP TABLE IF EXISTS ObjectScrips; +CREATE TABLE ObjectScrips ( + id INTEGER NOT NULL AUTO_INCREMENT, + Scrip integer NOT NULL , + Stage varchar(32) CHARACTER SET ascii NOT NULL DEFAULT 'TransactionCreate', + ObjectId integer NOT NULL, + SortOrder integer NOT NULL DEFAULT 0 , + + Creator integer NOT NULL DEFAULT 0 , + Created DATETIME NULL , + LastUpdatedBy integer NOT NULL DEFAULT 0 , + LastUpdated DATETIME NULL , + PRIMARY KEY (id) +) ENGINE=InnoDB CHARACTER SET utf8; +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; |