ch14.6-14.7
This commit is contained in:
26
internal/models/testdata/setup.sql
vendored
Normal file
26
internal/models/testdata/setup.sql
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
CREATE TABLE snippets (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(100) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created DATETIME NOT NULL,
|
||||
expires DATETIME NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX idx_snippets_created ON snippets(created);
|
||||
|
||||
CREATE TABLE users (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
hashed_password CHAR(60) NOT NULL,
|
||||
created DATETIME NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE users ADD CONSTRAINT users_uc_email UNIQUE (email);
|
||||
|
||||
INSERT INTO users (name, email, hashed_password, created) VALUES (
|
||||
'Alice Jones',
|
||||
'alice@example.com',
|
||||
'$2a$12$NuTjWXm3KKntReFwyBVHyuf/to.HEwTy.eS206TNfkGfr6HzGJSWG',
|
||||
'2022-01-01 10:00:00'
|
||||
);
|
||||
3
internal/models/testdata/teardown.sql
vendored
Normal file
3
internal/models/testdata/teardown.sql
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
DROP TABLE users;
|
||||
|
||||
DROP TABLE snippets;
|
||||
Reference in New Issue
Block a user