
CREATE DATABASE dragon_fire;

USE dragon_fire;

CREATE TABLE posts (
	post_id INTEGER AUTO_INCREMENT,

	post_path VARCHAR(255) NOT NULL,
	post_path_depth INTEGER NOT NULL DEFAULT 0,

	post_create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
	post_update_time DATETIME NOT NULL 
		DEFAULT CURRENT_TIMESTAMP
		ON UPDATE CURRENT_TIMESTAMP,

	post_metadata JSON NOT NULL,

	post_content MEDIUMTEXT,

	PRIMARY KEY(post_id),
	CONSTRAINT unique_post_path UNIQUE (post_path),

	INDEX(post_path, post_update_time),
	INDEX(post_path, post_create_time),
	INDEX(post_path_depth, post_path)
);


INSERT INTO posts (post_path, post_path_depth, post_metadata, post_content)
VALUES (
	'/about',
	0,
'
{
	"tags": ["test", "test2", "hellorld"],
	"brief": "This is a simple test indeed",
	"type": "text/markdown",
	"title": "About the dergen"
}
',
'
# About the dergs indeed

This is just a simple test. Might be nice, though!
'
), (
	'/about/neira',
	1,
'
{
	"tags": ["test", "test2", "hellorld", "neira"],
	"brief": "This is a soft grab of Neira",
	"type": "text/markdown",
	"title": "About her"
}
',
'
# Nothing here yet!

Sorry for this. She is working hard :>
'
), (
	'/about/xasin',
	1,
'
{
	"tags": ["test", "test2", "hellorld", "xasin"],
	"brief": "This is a soft grab of Xasin",
	"type": "text/markdown",
	"title": "About her"
}
',
'
# Nothing here yet!

Sorry for this. He is working hard :>
'
), (
	'/about/mesh',
	1,
'
{
	"tags": ["test", "test2", "hellorld", "mesh"],
	"brief": "This is a soft grab of Mesh",
	"type": "text/markdown",
	"title": "About her"
}
',
'
# Nothing here yet!

Sorry for this. Shi is working hard :>
'
), (
	'/about/alviere',
	1,
'
{
	"tags": ["test", "test2", "hellorld", "mesh"],
	"brief": "SHE GRABS",
	"type": "text/markdown",
	"title": "SHE GRABS"
}
',
'
# Nothing here yet!

Sorry for this. She GRABS A LOT
'
);