--liquibase formatted sql

--changeset mark.gidman:c9c903ea-f59b-4321-bae6-98285f08d642
CREATE TABLE account (
	id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
	name varchar(200) NOT NULL DEFAULT '',
	parent_id int(11) UNSIGNED DEFAULT NULL,
	rlms_id varchar(200) DEFAULT NULL,
	created_on datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
	updated_on datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
	created_by int(11) UNSIGNED NOT NULL,
	updated_by int(11) UNSIGNED NOT NULL,
	is_deleted tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
	PRIMARY KEY (id),
	KEY fk_account_parent_id (parent_id),
	INDEX ix_account_rlms_id (rlms_id),
	CONSTRAINT fk_account_parent_id FOREIGN KEY (parent_id) REFERENCES account (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Allows us to group users and isolate business entities.';
--rollback drop table user;


--changeset mark.gidman:e4cd684d-1085-47dc-a811-0e4bc23af4cf

/* Set up system account and user */
INSERT INTO account(id, name, parent_id, created_by, updated_by)
VALUES (1, 'system', null, 1, 1);

/* Set up SRC Corporate account and user */
INSERT INTO account(id, name, parent_id, created_by, updated_by)
VALUES (2, 'SRC Corporate', null, 1, 1);

/* Set up SRC Logistics account and user */
INSERT INTO account(id, name, parent_id, created_by, updated_by)
VALUES (3, 'SRC Logistics', 2, 1, 1);


--rollback delete from user where 1=1; delete from account where 1=1;
