Files
Portabase.Agent/scripts/seed.sql
T
charlesgauthereau 24ab764a6f First Commit.
2026-01-03 23:55:47 +01:00

33 lines
1.4 KiB
SQL

-- Drop tables if they exist
DROP TABLE IF EXISTS posts;
DROP TABLE IF EXISTS users;
-- Create users table
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create posts table
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(id) ON DELETE CASCADE,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert sample users
INSERT INTO users (username, email, password_hash) VALUES
('alice', 'alice@example.com', 'hashedpassword1'),
('bob', 'bob@example.com', 'hashedpassword2');
-- Insert sample posts
INSERT INTO posts (user_id, title, content) VALUES
(1, 'Hello World', 'This is the first post by Alice.'),
(2, 'Greetings', 'This is a post by Bob.'),
(1, 'Another Post', 'Alice writes again.');