root/trunk/components/dsl/resources/ome/dsl/data.vm
| Revision 2309, 4.7 kB (checked in by callan, 10 months ago) |
|---|
| Line | |
|---|---|
| 1 | -- |
| 2 | -- Copyright 2006 University of Dundee. All rights reserved. |
| 3 | -- Use is subject to license terms supplied in LICENSE.txt |
| 4 | -- |
| 5 | |
| 6 | -- |
| 7 | -- This file was generated by dsl/resources/ome/dsl/data.vm |
| 8 | -- |
| 9 | |
| 10 | begin; |
| 11 | set constraints all deferred; |
| 12 | |
| 13 | -- |
| 14 | -- First, we install a unique constraint so that it is only possible |
| 15 | -- to go from versionA/patchA to versionB/patchB once. |
| 16 | -- |
| 17 | alter table dbpatch add constraint unique_dbpatch unique (currentVersion, currentPatch, previousVersion, previousPatch); |
| 18 | |
| 19 | -- |
| 20 | -- Since this is a table that we will be using in DB-specific ways, we're also going |
| 21 | -- to make working with it a bit simpler. |
| 22 | -- |
| 23 | alter table dbpatch alter id set default nextval('seq_dbpatch'); |
| 24 | alter table dbpatch alter permissions set default -35; |
| 25 | alter table dbpatch alter message set default 'Updating'; |
| 26 | |
| 27 | -- |
| 28 | -- Then, we insert into the patch table the patch (initialization) which we are currently |
| 29 | -- running so that if anything goes wrong, we'll have some record. |
| 30 | -- |
| 31 | insert into dbpatch (currentVersion, currentPatch, previousVersion, previousPatch, message) |
| 32 | values ('@DBVERSION@', @DBPATCH@, '@DBVERSION@', 0, 'Initializing'); |
| 33 | |
| 34 | -- |
| 35 | -- Here we will create the root account and the necessary groups |
| 36 | -- |
| 37 | insert into experimenter (id,permissions,version,omename,firstname,lastname) |
| 38 | values (0,0,0,'root','root','root'); |
| 39 | insert into experimenter (id,permissions,version,omename,firstname,lastname) |
| 40 | values (nextval('seq_experimenter'),0,0,'guest','Guest','Account'); |
| 41 | insert into session |
| 42 | (id,permissions,timetoidle,timetolive,started,closed,defaultpermissions,defaulteventtype,uuid) |
| 43 | select 0,-35,0,0,now(),now(),'rw----','BOOTSTRAP',0000; |
| 44 | insert into session |
| 45 | (id,permissions,timetoidle,timetolive,started,closed,defaultpermissions,defaulteventtype,uuid) |
| 46 | select nextval('seq_session'),-35, 0,0,now(),now(),'rw----','PREVIOUSITEMS','1111'; |
| 47 | insert into event (id,permissions,time,status,experimenter,session) values (0,0,now(),'BOOTSTRAP',0,0); |
| 48 | insert into experimentergroup (id,permissions,version,owner_id,group_id,creation_id,update_id,name) |
| 49 | values (0,-35,0,0,0,0,0,'system'); |
| 50 | insert into experimentergroup (id,permissions,version,owner_id,group_id,creation_id,update_id,name) |
| 51 | values (nextval('seq_experimentergroup'),-35,0,0,0,0,0,'user'); |
| 52 | insert into experimentergroup (id,permissions,version,owner_id,group_id,creation_id,update_id,name) |
| 53 | values (nextval('seq_experimentergroup'),-35,0,0,0,0,0,'default'); |
| 54 | insert into experimentergroup (id,permissions,version,owner_id,group_id,creation_id,update_id,name) |
| 55 | values (nextval('seq_experimentergroup'),-35,0,0,0,0,0,'guest'); |
| 56 | insert into eventtype (id,permissions,owner_id,group_id,creation_id,value) values |
| 57 | (0,-35,0,0,0,'Bootstrap'); |
| 58 | insert into groupexperimentermap |
| 59 | (id,permissions,version,owner_id,group_id,creation_id,update_id, parent, child, child_index) |
| 60 | values |
| 61 | (0,-35,0,0,0,0,0,0,0,0); |
| 62 | insert into groupexperimentermap |
| 63 | (id,permissions,version,owner_id,group_id,creation_id,update_id, parent, child, child_index) |
| 64 | select nextval('seq_groupexperimentermap'),-35,0,0,0,0,0,1,0,1; |
| 65 | insert into groupexperimentermap |
| 66 | (id,permissions,version,owner_id,group_id,creation_id,update_id, parent, child, child_index) |
| 67 | select nextval('seq_groupexperimentermap'),-35,0,0,0,0,0,3,1,0; |
| 68 | |
| 69 | update event set type = 0; |
| 70 | update event set experimentergroup = 0; |
| 71 | |
| 72 | alter table event alter column type set not null; |
| 73 | alter table event alter column experimentergroup set not null; |
| 74 | |
| 75 | ##insert into event (id,version,name,e) select next, 0 as version, 'Bootstrap' |
| 76 | ## as name, next from (select nextval('seq_event') as next) as nv; |
| 77 | |
| 78 | ## ENUMS |
| 79 | #foreach($enum in $types) |
| 80 | #foreach($prop in $enum.properties) |
| 81 | #set($table = ${enum.typeToColumn($enum.id)} ) |
| 82 | #if($prop.class.name == "ome.dsl.EntryField") |
| 83 | insert into $table (id,permissions,owner_id,group_id,creation_id,value) |
| 84 | select nextval('seq_$table'),-35,0,0,0,'$prop.name'; |
| 85 | #end |
| 86 | #end |
| 87 | #end |
| 88 | |
| 89 | create table configuration ( name varchar(255) primary key, value text ); |
| 90 | |
| 91 | alter table pixels add column url varchar(2048); |
| 92 | alter table originalfile add column url varchar(2048); |
| 93 | alter table thumbnail add column url varchar(2048); |
| 94 | |
| 95 | create table password ( experimenter_id bigint unique not null REFERENCES experimenter (id) , hash char(24), dn text ); |
| 96 | insert into password values (0,'@ROOTPASS@'); |
| 97 | insert into password values (1,''); |
| 98 | -- root can now login with omero.rootpass property value |
| 99 | -- and guest can login with any value |
| 100 | |
| 101 | -- Here we have finished initializing this database. |
| 102 | update dbpatch set message = 'Database ready.', finished = now() |
| 103 | where currentVersion = '@DBVERSION@' and |
| 104 | currentPatch = @DBPATCH@ and |
| 105 | previousVersion = '@DBVERSION@' and |
| 106 | previousPatch = 0; |
| 107 | |
| 108 | commit; |
Note: See TracBrowser
for help on using the browser.
