Adding support in database for groups and permissions.
This commit is contained in:
parent
d45ae12c1d
commit
b0e9e7c35c
6
migrations/0000002_permissions.down.sql
Normal file
6
migrations/0000002_permissions.down.sql
Normal file
@ -0,0 +1,6 @@
|
||||
DROP TABLE IF EXISTS user_to_group;
|
||||
DROP INDEX IF EXISTS groups_index;
|
||||
DROP TABLE IF EXISTS groups;
|
||||
ALTER TABLE users DROP COLUMN IF EXISTS permissions;
|
||||
DROP INDEX IF EXISTS users_index;
|
||||
DROP EXTENSION IF EXISTS hstore;
|
22
migrations/0000002_permissions.up.sql
Normal file
22
migrations/0000002_permissions.up.sql
Normal file
@ -0,0 +1,22 @@
|
||||
CREATE EXTENSION IF NOT EXISTS hstore;
|
||||
CREATE INDEX users_index ON users (
|
||||
id,
|
||||
username
|
||||
);
|
||||
ALTER TABLE users ADD COLUMN permissions hstore;
|
||||
CREATE TABLE groups (
|
||||
id serial PRIMARY KEY,
|
||||
groupname text UNIQUE NOT NULL,
|
||||
permissions hstore
|
||||
);
|
||||
CREATE INDEX groups_index ON groups (
|
||||
id,
|
||||
groupname
|
||||
);
|
||||
CREATE TABLE user_to_group (
|
||||
id_group INTEGER,
|
||||
id_user INTEGER,
|
||||
PRIMARY KEY (id_group, id_user),
|
||||
FOREIGN KEY (id_group) REFERENCES groups (id),
|
||||
FOREIGN KEY (id_user) REFERENCES users (id)
|
||||
);
|
@ -14,6 +14,9 @@ import (
|
||||
|
||||
func DB() *sql.DB {
|
||||
configuration, err := config.New()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
url_postgres, err := configuration.DB.GetURL()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user