
-----------------------------------------------------------------------
-- content_block
-----------------------------------------------------------------------

DROP TABLE IF EXISTS content_block CASCADE;

CREATE TABLE content_block
(
	code VARCHAR(45) NOT NULL,
	content TEXT NOT NULL,
	created_at TIMESTAMP NOT NULL,
	created_by VARCHAR(45) NOT NULL,
	updated_at TIMESTAMP NOT NULL,
	updated_by VARCHAR(45) NOT NULL,
	PRIMARY KEY (code)
);

-----------------------------------------------------------------------
-- message
-----------------------------------------------------------------------

DROP TABLE IF EXISTS message CASCADE;

CREATE TABLE message
(
	message_id serial NOT NULL,
	first_name VARCHAR(45),
	last_name VARCHAR(45),
	interested_in VARCHAR(45),
	preferred_response VARCHAR(45),
	email VARCHAR(100),
	phone VARCHAR(11),
	zip VARCHAR(5),
	message TEXT,
	created_at TIMESTAMP,
	is_read INTEGER DEFAULT 0 NOT NULL,
	PRIMARY KEY (message_id)
);

-----------------------------------------------------------------------
-- page
-----------------------------------------------------------------------

DROP TABLE IF EXISTS page CASCADE;

CREATE TABLE page
(
	page_id serial NOT NULL,
	module VARCHAR(45) NOT NULL,
	action VARCHAR(45) NOT NULL,
	title VARCHAR(45) NOT NULL,
	sub_title VARCHAR(45),
	content TEXT,
	created_at TIMESTAMP NOT NULL,
	created_by VARCHAR(45) NOT NULL,
	updated_at TIMESTAMP NOT NULL,
	updated_by VARCHAR(45) NOT NULL,
	PRIMARY KEY (page_id),
	CONSTRAINT unq_page_1 UNIQUE (module,action)
);

-----------------------------------------------------------------------
-- testimonial
-----------------------------------------------------------------------

DROP TABLE IF EXISTS testimonial CASCADE;

CREATE TABLE testimonial
(
	testimonial_id serial NOT NULL,
	message TEXT,
	client_name VARCHAR(255),
	is_active INTEGER DEFAULT 0 NOT NULL,
	display_order INTEGER DEFAULT 10 NOT NULL,
	created_at TIMESTAMP NOT NULL,
	created_by VARCHAR(45) NOT NULL,
	updated_at TIMESTAMP NOT NULL,
	updated_by VARCHAR(45) NOT NULL,
	PRIMARY KEY (testimonial_id)
);

-----------------------------------------------------------------------
-- users
-----------------------------------------------------------------------

DROP TABLE IF EXISTS users CASCADE;

CREATE TABLE users
(
	user_id VARCHAR(45) NOT NULL,
	password VARCHAR(255) NOT NULL,
	created_at TIMESTAMP NOT NULL,
	updated_at TIMESTAMP NOT NULL,
	is_active INTEGER NOT NULL,
	created_by VARCHAR(45) NOT NULL,
	updated_by VARCHAR(45) NOT NULL,
	email VARCHAR(255) NOT NULL,
	PRIMARY KEY (user_id),
	CONSTRAINT unq_user_1 UNIQUE (email)
);
