Files
proxy/config/sql/init.sql

75 lines
2.4 KiB
MySQL
Raw Normal View History

2025-02-19 14:23:58 +08:00
-- nodes
2025-02-25 11:31:51 +08:00
drop table if exists nodes cascade;
create table nodes (
id serial primary key,
name varchar(255) not null unique,
provider varchar(255) not null,
location varchar(255) not null,
ip_address varchar(255) not null,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
2025-02-19 14:23:58 +08:00
);
2025-02-25 11:31:51 +08:00
create index devices_provider_index on nodes (provider);
create index devices_location_index on nodes (location);
2025-02-19 14:23:58 +08:00
-- users
2025-02-25 11:31:51 +08:00
drop table if exists users cascade;
create table users (
id serial primary key,
password varchar(255) not null,
username varchar(255) not null unique,
email varchar(255) not null unique,
phone varchar(255) not null unique,
name varchar(255) not null,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
2025-02-19 14:23:58 +08:00
);
-- user_ips
2025-02-25 11:31:51 +08:00
drop table if exists user_ips cascade;
create table user_ips (
id serial primary key,
user_id int not null references users (id)
on update cascade
on delete cascade,
ip_address varchar(255) not null,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
2025-02-19 14:23:58 +08:00
);
2025-02-25 11:31:51 +08:00
create index user_ips_user_id_index on user_ips (user_id);
create index user_ips_ip_address_index on user_ips (ip_address);
2025-02-19 14:23:58 +08:00
-- channel
2025-02-25 11:31:51 +08:00
drop table if exists channels cascade;
create table channels (
id serial primary key,
user_id int not null references users (id)
on update cascade
on delete cascade,
node_id int not null references nodes (id) --
on update cascade --
on delete set null, -- 节点删除后,用户侧需要保留提取记录
node_port int,
2025-02-25 11:31:51 +08:00
protocol varchar(255),
auth_ip bool,
auth_pass bool,
2025-02-25 11:31:51 +08:00
username varchar(255) unique,
password varchar(255),
expiration timestamp not null,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
2025-02-19 14:23:58 +08:00
);
2025-02-25 11:31:51 +08:00
create index channel_user_id_index on channels (user_id);
create index channel_node_id_index on channels (node_id);
create index channel_username_index on channels (username);
2025-02-19 14:23:58 +08:00
-- ====================
-- 填充数据
-- ====================