mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-05-02 21:22:49 +03:00
feat: init postgres implementation via sqlx
This commit is contained in:
parent
02abffd63a
commit
dba1f662a7
16 changed files with 308 additions and 4 deletions
db/db-sqlx-postgres/migrations
20210310122154_mcaptcha_users.sql20210310122617_mcaptcha_config.sql20210310122902_mcaptcha_levels.sql20210430032935_mcaptcha_pow_fetched_stats.sql20210509135118_mcaptcha_pow_solved_stats.sql20210509135154_mcaptcha_pow_confirmed_stats.sql20210509151150_mcaptcha_notifications.sql20211202141927_mcaptcha_sitekey_user_provided_avg_traffic.sql20211218133703_change_user_provided_avg_traffic_col_datatype.sql
|
@ -0,0 +1,8 @@
|
|||
CREATE TABLE IF NOT EXISTS mcaptcha_users (
|
||||
name VARCHAR(100) NOT NULL UNIQUE,
|
||||
email VARCHAR(100) UNIQUE DEFAULT NULL,
|
||||
email_verified BOOLEAN DEFAULT NULL,
|
||||
secret varchar(50) NOT NULL UNIQUE,
|
||||
password TEXT NOT NULL,
|
||||
ID SERIAL PRIMARY KEY NOT NULL
|
||||
);
|
|
@ -0,0 +1,7 @@
|
|||
CREATE TABLE IF NOT EXISTS mcaptcha_config (
|
||||
config_id SERIAL PRIMARY KEY NOT NULL,
|
||||
user_id INTEGER NOT NULL references mcaptcha_users(ID) ON DELETE CASCADE,
|
||||
key varchar(100) NOT NULL UNIQUE,
|
||||
name varchar(100) NOT NULL,
|
||||
duration integer NOT NULL DEFAULT 30
|
||||
);
|
|
@ -0,0 +1,6 @@
|
|||
CREATE TABLE IF NOT EXISTS mcaptcha_levels (
|
||||
config_id INTEGER references mcaptcha_config(config_id) ON DELETE CASCADE,
|
||||
difficulty_factor INTEGER NOT NULL,
|
||||
visitor_threshold INTEGER NOT NULL,
|
||||
level_id SERIAL PRIMARY KEY NOT NULL
|
||||
);
|
|
@ -0,0 +1,4 @@
|
|||
CREATE TABLE IF NOT EXISTS mcaptcha_pow_fetched_stats (
|
||||
config_id INTEGER references mcaptcha_config(config_id) ON DELETE CASCADE,
|
||||
time timestamptz NOT NULL DEFAULT now()
|
||||
);
|
|
@ -0,0 +1,4 @@
|
|||
CREATE TABLE IF NOT EXISTS mcaptcha_pow_solved_stats (
|
||||
config_id INTEGER references mcaptcha_config(config_id) ON DELETE CASCADE,
|
||||
time timestamptz NOT NULL DEFAULT now()
|
||||
);
|
|
@ -0,0 +1,4 @@
|
|||
CREATE TABLE IF NOT EXISTS mcaptcha_pow_confirmed_stats (
|
||||
config_id INTEGER references mcaptcha_config(config_id) ON DELETE CASCADE,
|
||||
time timestamptz NOT NULL DEFAULT now()
|
||||
);
|
|
@ -0,0 +1,10 @@
|
|||
-- Add migration script here
|
||||
CREATE TABLE IF NOT EXISTS mcaptcha_notifications (
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
tx INTEGER NOT NULL references mcaptcha_users(ID) ON DELETE CASCADE,
|
||||
rx INTEGER NOT NULL references mcaptcha_users(ID) ON DELETE CASCADE,
|
||||
heading varchar(30) NOT NULL,
|
||||
message varchar(250) NOT NULL,
|
||||
read BOOLEAN DEFAULT NULL,
|
||||
received timestamptz NOT NULL DEFAULT now()
|
||||
);
|
|
@ -0,0 +1,6 @@
|
|||
CREATE TABLE IF NOT EXISTS mcaptcha_sitekey_user_provided_avg_traffic (
|
||||
config_id INTEGER PRIMARY KEY UNIQUE NOT NULL references mcaptcha_config(config_id) ON DELETE CASCADE,
|
||||
avg_traffic INTEGER DEFAULT NULL,
|
||||
peak_sustainable_traffic INTEGER DEFAULT NULL,
|
||||
broke_my_site_traffic INTEGER DEFAULT NULL
|
||||
);
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE mcaptcha_sitekey_user_provided_avg_traffic
|
||||
ALTER COLUMN avg_traffic SET NOT NULL,
|
||||
ALTER COLUMN peak_sustainable_traffic SET NOT NULL;
|
Loading…
Add table
Add a link
Reference in a new issue