CREATE TABLE permissions (
    id serial4 NOT NULL,
    name VARCHAR(100) NOT NULL,

    created_by INT,
    updated_by INT,

    created_at TIMESTAMP DEFAULT now(),
    updated_at TIMESTAMP DEFAULT now(),
    deleted_at TIMESTAMP,

    CONSTRAINT permissions_pkey PRIMARY KEY (id)
);
CREATE UNIQUE INDEX permissions_name_unique_not_deleted ON permissions(name) WHERE deleted_at IS NULL;

-- seed permissions
INSERT INTO permissions (name, created_by, updated_by) VALUES
('user:create', 1, 1),
('user:update', 1, 1),
('user:delete', 1, 1),
('user:view', 1, 1),

('permission:create', 1, 1),
('permission:update', 1, 1),
('permission:delete', 1, 1),
('permission:view', 1, 1),

('role:create', 1, 1),
('role:view', 1, 1),
('role:update', 1, 1),
('role:delete', 1, 1),

('unit:create', 2, 1),
('unit:view', 2, 1),
('unit:update', 2, 1),
('unit:delete', 2, 1),

('report:view', 1, 1),
('admin:panel', 1, 1);