Skip to content
Myr

schema.sql

This file

Path

examples/tutorial/flaskr/schema.sql

20 lines · 498 bytes · SQL

Last changed by

Merge pull request #2676 from davidism/tutorialDavid Lordbefore adoptionc3e2ff2

History of this file

Take it

1-- Initialize the database.2-- Drop any existing data and create empty tables.34DROP TABLE IF EXISTS user;5DROP TABLE IF EXISTS post;67CREATE TABLE user (8  id INTEGER PRIMARY KEY AUTOINCREMENT,9  username TEXT UNIQUE NOT NULL,10  password TEXT NOT NULL11);1213CREATE TABLE post (14  id INTEGER PRIMARY KEY AUTOINCREMENT,15  author_id INTEGER NOT NULL,16  created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,17  title TEXT NOT NULL,18  body TEXT NOT NULL,19  FOREIGN KEY (author_id) REFERENCES user (id)20);