1# $Id$
2#
3# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
4#
5# Licensed under The MIT License
6# For full copyright and license information, please see the LICENSE.txt
7# Redistributions of files must retain the above copyright notice.
8# MIT License (https://opensource.org/licenses/mit-license.php)
9
10CREATE TABLE acos (
11  id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
12  parent_id INTEGER(10) DEFAULT NULL,
13  model VARCHAR(255) DEFAULT '',
14  foreign_key INTEGER(10) UNSIGNED DEFAULT NULL,
15  alias VARCHAR(255) DEFAULT '',
16  lft INTEGER(10) DEFAULT NULL,
17  rght INTEGER(10) DEFAULT NULL,
18  PRIMARY KEY  (id)
19);
20
21CREATE TABLE aros_acos (
22  id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
23  aro_id INTEGER(10) UNSIGNED NOT NULL,
24  aco_id INTEGER(10) UNSIGNED NOT NULL,
25  _create CHAR(2) NOT NULL DEFAULT 0,
26  _read CHAR(2) NOT NULL DEFAULT 0,
27  _update CHAR(2) NOT NULL DEFAULT 0,
28  _delete CHAR(2) NOT NULL DEFAULT 0,
29  PRIMARY KEY(id)
30);
31
32CREATE TABLE aros (
33  id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
34  parent_id INTEGER(10) DEFAULT NULL,
35  model VARCHAR(255) DEFAULT '',
36  foreign_key INTEGER(10) UNSIGNED DEFAULT NULL,
37  alias VARCHAR(255) DEFAULT '',
38  lft INTEGER(10) DEFAULT NULL,
39  rght INTEGER(10) DEFAULT NULL,
40  PRIMARY KEY  (id)
41);
42
43/* this indexes will improve acl performance */
44CREATE INDEX idx_acos_lft_rght ON `acos` (`lft`, `rght`);
45
46CREATE INDEX idx_acos_alias ON `acos` (`alias`);
47
48CREATE INDEX idx_aros_lft_rght ON `aros` (`lft`, `rght`);
49
50CREATE INDEX idx_aros_alias ON `aros` (`alias`);
51
52CREATE INDEX idx_aco_id ON `aros_acos` (`aco_id`);
53