-- ENUM Types CREATE TYPE userstatus AS ENUM ('active', 'inactive', 'banned'); CREATE…
- User
-- ENUM Types CREATE TYPE user_status AS ENUM ('active', 'inactive', 'banned'); CREATE TYPE permission_type AS ENUM ('menu', 'resource', 'button'); CREATE TYPE target_type AS ENUM ('user', 'role', 'menu', 'resource', 'button');
-- Users Table CREATE TABLE sys_user ( id SERIAL PRIMARY KEY, username VARCHAR(50) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL, status user_status DEFAULT 'active', created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, created_by INT NOT NULL, updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, updated_by INT NOT NULL );
-- Add index for frequent queries CREATE INDEX idx_sys_user_username ON sys_user (username);
-- Users Table's Comment COMMENT ON TABLE sys_user IS 'Stores system users and their authentication details'; COMMENT ON COLUMN sys_user.id IS 'Unique identifier for each user'; COMMENT ON COLUMN sys_user.username IS 'Unique username for login'; COMMENT ON COLUMN sys_user.password IS 'Encrypted user password (bcrypt)'; COMMENT ON COLUMN sys_user.status IS 'Account status: active, inactive, banned'; COMMENT ON COLUMN sys_user.created_at IS 'Timestamp when the user was created'; COMMENT ON COLUMN sys_user.created_by IS 'User id of the creator'; COMMENT ON COLUMN sys_user.updated_at IS 'Timestamp of the last update'; COMMENT ON COLUMN sys_user.updated_by IS 'User id of the last user who updated the record';
-- Roles Table CREATE TABLE sys_role ( id SERIAL PRIMARY KEY, name VARCHAR(50) UNIQUE NOT NULL, description VARCHAR(500), -- Changed from TEXT for better performance created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, created_by INT NOT NULL, updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, updated_by INT NOT NULL );
-- Add index for role name lookups CREATE INDEX idx_sys_role_name ON sys_role (name);
-- Roles Table's Comment COMMENT ON TABLE sys_role IS 'Stores roles in the system'; COMMENT ON COLUMN sys_role.id IS 'Unique identifier for each role'; COMMENT ON COLUMN sys_role.name IS 'Role name (e.g., ROLE_ADMIN, ROLE_EDITOR)'; COMMENT ON COLUMN sys_role.description IS 'Detailed description of the role'; COMMENT ON COLUMN sys_role.created_at IS 'Timestamp when the role was created'; COMMENT ON COLUMN sys_role.created_by IS 'User id of the creator'; COMMENT ON COLUMN sys_role.updated_at IS 'Timestamp of the last update'; COMMENT ON COLUMN sys_role.updated_by IS 'User id of the last user who updated the record';
-- User-Role Mapping Table (Many-to-Many) CREATE TABLE sys_user_role ( user_id INT NOT NULL, role_id INT NOT NULL, created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, created_by INT NOT NULL, PRIMARY KEY (user_id, role_id) );
-- Add indexes for efficient lookups CREATE INDEX idx_sys_user_role_user ON sys_user_role (user_id); CREATE INDEX idx_sys_user_role_role ON sys_user_role (role_id);
-- User-Role Mapping Table's Comment COMMENT ON TABLE sys_user_role IS 'Links users to roles in a many-to-many relationship'; COMMENT ON COLUMN sys_user_role.user_id IS 'ID of the user assigned to the role'; COMMENT ON COLUMN sys_user_role.role_id IS 'ID of the assigned role'; COMMENT ON COLUMN sys_user_role.created_at IS 'Timestamp when the user assigned to the role'; COMMENT ON COLUMN sys_user_role.created_by IS 'User id of the creator';
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.