server/sources/native.py
changeset 10626 93f8d239c708
parent 10575 036f5964e6fe
child 10627 ffef8ac383f4
equal deleted inserted replaced
10625:684dbf6722ef 10626:93f8d239c708
  1398 
  1398 
  1399 CREATE TABLE entities (
  1399 CREATE TABLE entities (
  1400   eid INTEGER PRIMARY KEY NOT NULL,
  1400   eid INTEGER PRIMARY KEY NOT NULL,
  1401   type VARCHAR(64) NOT NULL,
  1401   type VARCHAR(64) NOT NULL,
  1402   asource VARCHAR(128) NOT NULL,
  1402   asource VARCHAR(128) NOT NULL,
  1403   extid VARCHAR(256) UNIQUE
  1403   extid VARCHAR(256)
  1404 );;
  1404 );;
  1405 CREATE INDEX entities_type_idx ON entities(type);;
  1405 CREATE INDEX entities_type_idx ON entities(type);;
  1406 CREATE TABLE moved_entities (
  1406 CREATE TABLE moved_entities (
  1407   eid INTEGER PRIMARY KEY NOT NULL,
  1407   eid INTEGER PRIMARY KEY NOT NULL,
  1408   extid VARCHAR(256) UNIQUE
  1408   extid VARCHAR(256) UNIQUE
  1456 FOR EACH ROW BEGIN
  1456 FOR EACH ROW BEGIN
  1457     DELETE FROM tx_entity_actions WHERE tx_uuid=OLD.tx_uuid;
  1457     DELETE FROM tx_entity_actions WHERE tx_uuid=OLD.tx_uuid;
  1458     DELETE FROM tx_relation_actions WHERE tx_uuid=OLD.tx_uuid;
  1458     DELETE FROM tx_relation_actions WHERE tx_uuid=OLD.tx_uuid;
  1459 END;;
  1459 END;;
  1460 '''
  1460 '''
       
  1461     schema += ';;'.join(helper.sqls_create_multicol_unique_index('entities', ['extid']))
       
  1462     schema += ';;\n'
  1461     return schema
  1463     return schema
  1462 
  1464 
  1463 
  1465 
  1464 def sql_drop_schema(driver):
  1466 def sql_drop_schema(driver):
  1465     helper = get_db_helper(driver)
  1467     helper = get_db_helper(driver)
  1466     return """
  1468     return """
       
  1469 %s;
  1467 %s
  1470 %s
  1468 DROP TABLE entities;
  1471 DROP TABLE entities;
  1469 DROP TABLE tx_entity_actions;
  1472 DROP TABLE tx_entity_actions;
  1470 DROP TABLE tx_relation_actions;
  1473 DROP TABLE tx_relation_actions;
  1471 DROP TABLE transactions;
  1474 DROP TABLE transactions;
  1472 """ % helper.sql_drop_numrange('entities_id_seq')
  1475 """ % (';'.join(helper.sqls_drop_multicol_unique_index('entities', ['extid'])),
       
  1476        helper.sql_drop_numrange('entities_id_seq'))
  1473 
  1477 
  1474 
  1478 
  1475 def grant_schema(user, set_owner=True):
  1479 def grant_schema(user, set_owner=True):
  1476     result = ''
  1480     result = ''
  1477     for table in ('entities', 'entities_id_seq',
  1481     for table in ('entities', 'entities_id_seq',