mirror of
https://github.com/solero/houdini.git
synced 2024-11-25 15:07:24 +00:00
Index permissions by name
This commit is contained in:
parent
4288248864
commit
99194d79f3
13
houdini.sql
13
houdini.sql
@ -696,32 +696,31 @@ COMMENT ON COLUMN activation_key.activation_key IS 'Penguin activation key';
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS permission;
|
DROP TABLE IF EXISTS permission;
|
||||||
CREATE TABLE permission (
|
CREATE TABLE permission (
|
||||||
id SERIAL NOT NULL,
|
|
||||||
name VARCHAR(50) NOT NULL,
|
name VARCHAR(50) NOT NULL,
|
||||||
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (name)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE UNIQUE INDEX permission_name ON permission(name);
|
CREATE UNIQUE INDEX permission_name ON permission(name);
|
||||||
|
|
||||||
COMMENT ON TABLE permission IS 'Registered server permissions';
|
COMMENT ON TABLE permission IS 'Registered server permissions';
|
||||||
|
|
||||||
COMMENT ON COLUMN permission.id IS 'Unique permission ID';
|
|
||||||
COMMENT ON COLUMN permission.name IS 'Unique permission identifier';
|
COMMENT ON COLUMN permission.name IS 'Unique permission identifier';
|
||||||
|
|
||||||
DROP TABLE IF EXISTS penguin_permission;
|
DROP TABLE IF EXISTS penguin_permission;
|
||||||
CREATE TABLE penguin_permission (
|
CREATE TABLE penguin_permission (
|
||||||
penguin_id INT NOT NULL,
|
penguin_id INT NOT NULL,
|
||||||
permission_id INT NOT NULL,
|
permission_name VARCHAR(50) NOT NULL,
|
||||||
PRIMARY KEY (penguin_id),
|
PRIMARY KEY (penguin_id, permission_name),
|
||||||
CONSTRAINT penguin_permission_ibfk_1 FOREIGN KEY (penguin_id) REFERENCES penguin(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
CONSTRAINT penguin_permission_ibfk_1 FOREIGN KEY (penguin_id) REFERENCES penguin(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT penguin_permission_ibfk_2 FOREIGN KEY (permission_id) REFERENCES permission(id) ON DELETE CASCADE ON UPDATE CASCADE
|
CONSTRAINT penguin_permission_ibfk_2 FOREIGN KEY (permission_name) REFERENCES permission(name) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
COMMENT ON TABLE penguin_permission IS 'Penguin permissions';
|
COMMENT ON TABLE penguin_permission IS 'Penguin permissions';
|
||||||
|
|
||||||
COMMENT ON COLUMN penguin_permission.penguin_id IS 'Penguin ID';
|
COMMENT ON COLUMN penguin_permission.penguin_id IS 'Penguin ID';
|
||||||
COMMENT ON COLUMN penguin_permission.permission_id IS 'Penguin permission ID';
|
COMMENT ON COLUMN penguin_permission.permission_name IS 'Penguin permission name';
|
||||||
|
|
||||||
DROP TABLE IF EXISTS penguin_attribute;
|
DROP TABLE IF EXISTS penguin_attribute;
|
||||||
CREATE TABLE penguin_attribute (
|
CREATE TABLE penguin_attribute (
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
|
@ -4,8 +4,7 @@ from houdini.data import AbstractDataCollection, db
|
|||||||
class Permission(db.Model):
|
class Permission(db.Model):
|
||||||
__tablename__ = 'permission'
|
__tablename__ = 'permission'
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True, server_default=db.text("nextval('\"permission_id_seq\"'::regclass)"))
|
name = db.Column(db.String(50), nullable=False, primary_key=True)
|
||||||
name = db.Column(db.String(50), nullable=False, unique=True)
|
|
||||||
enabled = db.Column(db.Boolean, nullable=False, server_default=db.text("true"))
|
enabled = db.Column(db.Boolean, nullable=False, server_default=db.text("true"))
|
||||||
|
|
||||||
|
|
||||||
@ -13,7 +12,8 @@ class PenguinPermission(db.Model):
|
|||||||
__tablename__ = 'penguin_permission'
|
__tablename__ = 'penguin_permission'
|
||||||
|
|
||||||
penguin_id = db.Column(db.ForeignKey(u'penguin.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), primary_key=True)
|
penguin_id = db.Column(db.ForeignKey(u'penguin.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), primary_key=True)
|
||||||
permission_id = db.Column(db.ForeignKey(u'permission.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), nullable=False)
|
permission_name = db.Column(db.ForeignKey(u'permission.name', ondelete=u'CASCADE', onupdate=u'CASCADE'),
|
||||||
|
nullable=False, primary_key=True)
|
||||||
|
|
||||||
|
|
||||||
class PermissionCollection(AbstractDataCollection):
|
class PermissionCollection(AbstractDataCollection):
|
||||||
@ -24,5 +24,5 @@ class PermissionCollection(AbstractDataCollection):
|
|||||||
|
|
||||||
class PenguinPermissionCollection(AbstractDataCollection):
|
class PenguinPermissionCollection(AbstractDataCollection):
|
||||||
__model__ = PenguinPermission
|
__model__ = PenguinPermission
|
||||||
__indexby__ = 'permission_id'
|
__indexby__ = 'permission_name'
|
||||||
__filterby__ = 'penguin_id'
|
__filterby__ = 'penguin_id'
|
||||||
|
Loading…
Reference in New Issue
Block a user