cubicweb/misc/migration/3.7.0_Any.py
changeset 11057 0b59724cb3f2
parent 4913 083b4d454192
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
       
     1 typemap = repo.system_source.dbhelper.TYPE_MAPPING
       
     2 sqls = """
       
     3 CREATE TABLE transactions (
       
     4   tx_uuid CHAR(32) PRIMARY KEY NOT NULL,
       
     5   tx_user INTEGER NOT NULL,
       
     6   tx_time %s NOT NULL
       
     7 );;
       
     8 CREATE INDEX transactions_tx_user_idx ON transactions(tx_user);;
       
     9 
       
    10 CREATE TABLE tx_entity_actions (
       
    11   tx_uuid CHAR(32) REFERENCES transactions(tx_uuid) ON DELETE CASCADE,
       
    12   txa_action CHAR(1) NOT NULL,
       
    13   txa_public %s NOT NULL,
       
    14   txa_order INTEGER,
       
    15   eid INTEGER NOT NULL,
       
    16   etype VARCHAR(64) NOT NULL,
       
    17   changes %s
       
    18 );;
       
    19 CREATE INDEX tx_entity_actions_txa_action_idx ON tx_entity_actions(txa_action);;
       
    20 CREATE INDEX tx_entity_actions_txa_public_idx ON tx_entity_actions(txa_public);;
       
    21 CREATE INDEX tx_entity_actions_eid_idx ON tx_entity_actions(eid);;
       
    22 CREATE INDEX tx_entity_actions_etype_idx ON tx_entity_actions(etype);;
       
    23 
       
    24 CREATE TABLE tx_relation_actions (
       
    25   tx_uuid CHAR(32) REFERENCES transactions(tx_uuid) ON DELETE CASCADE,
       
    26   txa_action CHAR(1) NOT NULL,
       
    27   txa_public %s NOT NULL,
       
    28   txa_order INTEGER,
       
    29   eid_from INTEGER NOT NULL,
       
    30   eid_to INTEGER NOT NULL,
       
    31   rtype VARCHAR(256) NOT NULL
       
    32 );;
       
    33 CREATE INDEX tx_relation_actions_txa_action_idx ON tx_relation_actions(txa_action);;
       
    34 CREATE INDEX tx_relation_actions_txa_public_idx ON tx_relation_actions(txa_public);;
       
    35 CREATE INDEX tx_relation_actions_eid_from_idx ON tx_relation_actions(eid_from);;
       
    36 CREATE INDEX tx_relation_actions_eid_to_idx ON tx_relation_actions(eid_to)
       
    37 """ % (typemap['Datetime'],
       
    38        typemap['Boolean'], typemap['Bytes'], typemap['Boolean'])
       
    39 for statement in sqls.split(';;'):
       
    40     sql(statement)