Skip to content

Instantly share code, notes, and snippets.

@danielnolan
Created June 7, 2011 14:03
Show Gist options
  • Save danielnolan/1012315 to your computer and use it in GitHub Desktop.
Save danielnolan/1012315 to your computer and use it in GitHub Desktop.

Revisions

  1. danielnolan renamed this gist Jun 7, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. danielnolan created this gist Jun 7, 2011.
    44 changes: 44 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    /* ACL Tables */

    CREATE TABLE acos (
    id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    parent_id INT DEFAULT NULL,
    model VARCHAR(255) DEFAULT '',
    foreign_key INT UNSIGNED DEFAULT NULL,
    alias VARCHAR(255) DEFAULT '',
    lft INT DEFAULT NULL,
    rght INT DEFAULT NULL
    ) ENGINE = INNODB;
    -- table name is quoted because it is a reserved word
    CREATE INDEX idx_acos_lft_rght ON `acos`(lft,rght);
    CREATE INDEX idx_acos_alias ON `acos`(alias);
    CREATE INDEX idx_acos_model_foreign_key ON `acos`(model(255),foreign_key);

    CREATE TABLE aros (
    id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    parent_id INT DEFAULT NULL,
    model VARCHAR(255) DEFAULT '',
    foreign_key INT UNSIGNED DEFAULT NULL,
    alias VARCHAR(255) DEFAULT '',
    lft INT DEFAULT NULL,
    rght INT DEFAULT NULL
    ) ENGINE = INNODB;
    -- table name is quoted because it is a reserved word
    CREATE INDEX idx_aros_lft_rght ON `aros`(lft,rght);
    CREATE INDEX idx_aros_alias ON `aros`(alias);
    CREATE INDEX idx_aros_model_foreign_key ON `aros`(model(255),foreign_key);

    CREATE TABLE aros_acos (
    id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    aro_id INT UNSIGNED NOT NULL,
    aco_id INT UNSIGNED NOT NULL,
    _create CHAR(2) NOT NULL DEFAULT 0,
    _read CHAR(2) NOT NULL DEFAULT 0,
    _update CHAR(2) NOT NULL DEFAULT 0,
    _delete CHAR(2) NOT NULL DEFAULT 0
    ) ENGINE = INNODB;
    -- table names are quoted because they are reserved words
    CREATE UNIQUE INDEX idx_aros_acos_aro_id_aco_id ON `aros_acos`(aro_id, aco_id);
    ALTER TABLE aros_acos ADD CONSTRAINT FOREIGN KEY (aro_id) REFERENCES `aros`(id);
    ALTER TABLE aros_acos ADD CONSTRAINT FOREIGN KEY (aco_id) REFERENCES `acos`(id);