Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 32 lines (26 sloc) 1.323 kb
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
CREATE TABLE IF NOT EXISTS shards (
    class_name VARCHAR(125) NOT NULL,
    table_prefix VARCHAR(125) NOT NULL,
    hostname VARCHAR(25) NOT NULL,
    source_type VARCHAR(125),
    destination_type VARCHAR(125),
    busy TINYINT NOT NULL DEFAULT 0,

   PRIMARY KEY primary_key_table_prefix_hostname (hostname, table_prefix)
) ENGINE=INNODB;

CREATE TABLE IF NOT EXISTS shard_children (
    parent_hostname VARCHAR(125) NOT NULL,
    parent_table_prefix VARCHAR(125) NOT NULL,
    child_hostname VARCHAR(125) NOT NULL,
    child_table_prefix VARCHAR(125) NOT NULL,
    weight INT NOT NULL DEFAULT 1,

    PRIMARY KEY primary_key_family (parent_hostname, parent_table_prefix, child_hostname, child_table_prefix),
    INDEX child (child_hostname, child_table_prefix)
) ENGINE=INNODB;

CREATE TABLE IF NOT EXISTS forwardings (
    base_source_id BIGINT NOT NULL,
    table_id INT NOT NULL,
    shard_hostname VARCHAR(125) NOT NULL,
    shard_table_prefix VARCHAR(125) NOT NULL,

    PRIMARY KEY (base_source_id, table_id),

    UNIQUE unique_shard (shard_hostname, shard_table_prefix)
) ENGINE=INNODB;
Something went wrong with that request. Please try again.