channels.username 设置为 unique

This commit is contained in:
2025-02-25 11:31:51 +08:00
parent 09f80662fd
commit 6df7c94d37
2 changed files with 54 additions and 58 deletions

View File

@@ -1,71 +1,71 @@
-- nodes -- nodes
DROP TABLE IF EXISTS nodes CASCADE; drop table if exists nodes cascade;
CREATE TABLE nodes ( create table nodes (
id SERIAL PRIMARY KEY, id serial primary key,
name VARCHAR(255) NOT NULL UNIQUE, name varchar(255) not null unique,
provider VARCHAR(255) NOT NULL, provider varchar(255) not null,
location VARCHAR(255) NOT NULL, location varchar(255) not null,
ip_address VARCHAR(255) NOT NULL, ip_address varchar(255) not null,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at timestamp default current_timestamp,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at timestamp default current_timestamp,
deleted_at TIMESTAMP deleted_at timestamp
); );
CREATE INDEX devices_provider_index ON nodes (provider); create index devices_provider_index on nodes (provider);
CREATE INDEX devices_location_index ON nodes (location); create index devices_location_index on nodes (location);
-- users -- users
DROP TABLE IF EXISTS users CASCADE; drop table if exists users cascade;
CREATE TABLE users ( create table users (
id SERIAL PRIMARY KEY, id serial primary key,
password VARCHAR(255) NOT NULL, password varchar(255) not null,
username VARCHAR(255) NOT NULL UNIQUE, username varchar(255) not null unique,
email VARCHAR(255) NOT NULL UNIQUE, email varchar(255) not null unique,
phone VARCHAR(255) NOT NULL UNIQUE, phone varchar(255) not null unique,
name VARCHAR(255) NOT NULL, name varchar(255) not null,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at timestamp default current_timestamp,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at timestamp default current_timestamp,
deleted_at TIMESTAMP deleted_at timestamp
); );
-- user_ips -- user_ips
DROP TABLE IF EXISTS user_ips CASCADE; drop table if exists user_ips cascade;
CREATE TABLE user_ips ( create table user_ips (
id SERIAL PRIMARY KEY, id serial primary key,
user_id int NOT NULL REFERENCES users (id) user_id int not null references users (id)
ON UPDATE CASCADE on update cascade
ON DELETE CASCADE, on delete cascade,
ip_address VARCHAR(255) NOT NULL, ip_address varchar(255) not null,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at timestamp default current_timestamp,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at timestamp default current_timestamp,
deleted_at TIMESTAMP deleted_at timestamp
); );
CREATE INDEX user_ips_user_id_index ON user_ips (user_id); create index user_ips_user_id_index on user_ips (user_id);
CREATE INDEX user_ips_ip_address_index ON user_ips (ip_address); create index user_ips_ip_address_index on user_ips (ip_address);
-- channel -- channel
DROP TABLE IF EXISTS channels CASCADE; drop table if exists channels cascade;
CREATE TABLE channels ( create table channels (
id SERIAL PRIMARY KEY, id serial primary key,
user_id int NOT NULL REFERENCES users (id) user_id int not null references users (id)
ON UPDATE CASCADE on update cascade
ON DELETE CASCADE, on delete cascade,
node_id int NOT NULL REFERENCES nodes (id) -- node_id int not null references nodes (id) --
ON UPDATE CASCADE -- on update cascade --
ON DELETE SET NULL, -- 节点删除后,用户侧需要保留提取记录 on delete set null, -- 节点删除后,用户侧需要保留提取记录
node_port int, node_port int,
protocol VARCHAR(255), protocol varchar(255),
auth_ip bool, auth_ip bool,
auth_pass bool, auth_pass bool,
username VARCHAR(255), username varchar(255) unique,
password VARCHAR(255), password varchar(255),
expiration TIMESTAMP NOT NULL, expiration timestamp not null,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at timestamp default current_timestamp,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at timestamp default current_timestamp,
deleted_at TIMESTAMP deleted_at timestamp
); );
CREATE INDEX channel_user_id_index ON channels (user_id); create index channel_user_id_index on channels (user_id);
CREATE INDEX channel_node_id_index ON channels (node_id); create index channel_node_id_index on channels (node_id);
CREATE INDEX channel_username_index ON channels (username); create index channel_username_index on channels (username);
-- ==================== -- ====================
-- 填充数据 -- 填充数据

View File

@@ -1,4 +0,0 @@
====================
删除 channels.target_snapshot 不需要目标地址快照
添加 channels.auth_ip 是否验证白名单
添加 channels.auth_pass 是否验证密码