Initial commit - Mini CMS complet (PHP + Docker + MinIO)
This commit is contained in:
33
infrastructure/setup-mysql/init-schema.sql
Normal file
33
infrastructure/setup-mysql/init-schema.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
CREATE TABLE IF NOT EXISTS utilisateurs (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(50) NOT NULL UNIQUE,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(100) UNIQUE,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS posts (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
title VARCHAR(100) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES utilisateurs(id)
|
||||
);
|
||||
|
||||
INSERT INTO utilisateurs (username, password, email)
|
||||
VALUES
|
||||
('aya', 'password123', 'ayae@example.com'),
|
||||
('tess', 'password456', 'tess@example.com');
|
||||
|
||||
INSERT INTO posts (user_id, title, content)
|
||||
VALUES
|
||||
(1, 'Bienvenue sur le forum', 'Ceci est le premier post !'),
|
||||
(2, 'Deuxième post', 'Un autre test pour vérifier la base.');
|
||||
ALTER TABLE posts
|
||||
DROP FOREIGN KEY posts_ibfk_1;
|
||||
|
||||
ALTER TABLE posts
|
||||
ADD CONSTRAINT posts_ibfk_1
|
||||
FOREIGN KEY (user_id) REFERENCES utilisateurs(id)
|
||||
ON DELETE CASCADE;
|
||||
Reference in New Issue
Block a user