This commit is contained in:
2026-01-19 05:35:37 +03:00
commit cbbc605336
20 changed files with 841 additions and 0 deletions

32
db/schema.sql Normal file
View File

@@ -0,0 +1,32 @@
CREATE DATABASE IF NOT EXISTS auth_db
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
USE auth_db;
CREATE TABLE IF NOT EXISTS users (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
login VARCHAR(64) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS user_access (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
user_id INT UNSIGNED NOT NULL,
site_key VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY unique_access (user_id, site_key),
CONSTRAINT fk_user_access_user
FOREIGN KEY (user_id) REFERENCES users(id)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- Пример:
-- INSERT INTO users (login, password_hash)
-- VALUES ('demo', '$2a$10$YOUR_BCRYPT_HASH_HERE');
--
-- INSERT INTO user_access (user_id, site_key)
-- VALUES (1, 'example.com');