CREATE TABLE banner (id BIGINT AUTO_INCREMENT, type_id BIGINT NOT NULL, profile_id BIGINT NOT NULL, filename VARCHAR(255), note VARCHAR(255), limit_from DATE, limit_to DATE, limit_clicks BIGINT, limit_views BIGINT, clicks_count BIGINT DEFAULT 0, views_count BIGINT DEFAULT 0, is_active TINYINT(1) DEFAULT '1' NOT NULL, last_show datetime, show_token TINYINT(1) DEFAULT '0' NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX type_id_idx (type_id), INDEX profile_id_idx (profile_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE banner_click (id BIGINT AUTO_INCREMENT, banner_id BIGINT NOT NULL, ip VARCHAR(255), url VARCHAR(255), user_agent VARCHAR(255), created_at DATETIME NOT NULL, INDEX banner_id_idx (banner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE banner_region_relation (banner_id BIGINT, region_id BIGINT, PRIMARY KEY(banner_id, region_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE banner_type (id BIGINT AUTO_INCREMENT, name VARCHAR(255), width BIGINT, height BIGINT, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE banner_view (id BIGINT AUTO_INCREMENT, banner_id BIGINT NOT NULL, ip VARCHAR(255), url VARCHAR(255), user_agent VARCHAR(255), created_at DATETIME NOT NULL, INDEX banner_id_idx (banner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE job (id BIGINT AUTO_INCREMENT, profile_id BIGINT, category_id BIGINT NOT NULL, type_id BIGINT NOT NULL, name VARCHAR(255) NOT NULL, city VARCHAR(255), street VARCHAR(255), zip BIGINT, text LONGTEXT, expiration datetime NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, slug VARCHAR(255), UNIQUE INDEX job_sluggable_idx (slug), INDEX profile_id_idx (profile_id), INDEX category_id_idx (category_id), INDEX type_id_idx (type_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE job_category (id BIGINT AUTO_INCREMENT, parent_id BIGINT, name VARCHAR(255) NOT NULL, priority BIGINT DEFAULT 100 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, slug VARCHAR(255), UNIQUE INDEX job_category_sluggable_idx (slug), INDEX parent_id_idx (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE job_region_relation (job_id BIGINT, region_id BIGINT, PRIMARY KEY(job_id, region_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE job_specialization (id BIGINT AUTO_INCREMENT, category_id BIGINT NOT NULL, name VARCHAR(255) NOT NULL, priority BIGINT DEFAULT 100 NOT NULL, INDEX category_id_idx (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE job_specialization_relation (job_id BIGINT, specialization_id BIGINT, PRIMARY KEY(job_id, specialization_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE job_type (id BIGINT AUTO_INCREMENT, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE page (id BIGINT AUTO_INCREMENT, title VARCHAR(255) NOT NULL, text LONGTEXT, is_deletable TINYINT(1) DEFAULT '1', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, slug VARCHAR(255), UNIQUE INDEX page_sluggable_idx (slug), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE prepayment_type (id BIGINT AUTO_INCREMENT, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE profile (id BIGINT AUTO_INCREMENT, user_id BIGINT NOT NULL, type_id BIGINT NOT NULL, name VARCHAR(255), first_name VARCHAR(255), last_name VARCHAR(255), prefix VARCHAR(255), sufix VARCHAR(255), tel VARCHAR(255), mail VARCHAR(255) NOT NULL UNIQUE, web VARCHAR(255), region_id BIGINT NOT NULL, city VARCHAR(255), street VARCHAR(255), zip BIGINT, text LONGTEXT, is_public TINYINT(1) DEFAULT '1' NOT NULL, prepayment_type_id BIGINT DEFAULT 1 NOT NULL, prepayment_count BIGINT, prepayment_from DATE, prepayment_to DATE, prepayment_active TINYINT(1) DEFAULT '0', filename VARCHAR(255), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, slug VARCHAR(255), UNIQUE INDEX profile_sluggable_idx (slug), INDEX user_id_idx (user_id), INDEX type_id_idx (type_id), INDEX prepayment_type_id_idx (prepayment_type_id), INDEX region_id_idx (region_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE profile_type (id BIGINT AUTO_INCREMENT, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE region (id BIGINT AUTO_INCREMENT, name VARCHAR(255), priority BIGINT DEFAULT 100 NOT NULL, coords LONGTEXT, slug VARCHAR(255), UNIQUE INDEX region_sluggable_idx (slug), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE top_job (id BIGINT AUTO_INCREMENT, job_id BIGINT, is_active TINYINT(1) DEFAULT '0', valid_from DATE, valid_to DATE, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX job_id_idx (job_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE sa_setting (id BIGINT AUTO_INCREMENT, name VARCHAR(255) NOT NULL UNIQUE, type VARCHAR(255) DEFAULT 'input' NOT NULL, widget_options LONGTEXT, value LONGTEXT, setting_group VARCHAR(255), slug VARCHAR(255), UNIQUE INDEX sa_setting_sluggable_idx (slug), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE sf_guard_forgot_password (id BIGINT AUTO_INCREMENT, user_id BIGINT NOT NULL, unique_key VARCHAR(255), expires_at DATETIME NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE sf_guard_group (id BIGINT AUTO_INCREMENT, name VARCHAR(255) UNIQUE, description TEXT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE sf_guard_group_permission (group_id BIGINT, permission_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(group_id, permission_id)) ENGINE = INNODB;
CREATE TABLE sf_guard_permission (id BIGINT AUTO_INCREMENT, name VARCHAR(255) UNIQUE, description TEXT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE sf_guard_remember_key (id BIGINT AUTO_INCREMENT, user_id BIGINT, remember_key VARCHAR(32), ip_address VARCHAR(50), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE sf_guard_user (id BIGINT AUTO_INCREMENT, first_name VARCHAR(255), last_name VARCHAR(255), email_address VARCHAR(255) NOT NULL UNIQUE, username VARCHAR(128) NOT NULL UNIQUE, algorithm VARCHAR(128) DEFAULT 'sha1' NOT NULL, salt VARCHAR(128), password VARCHAR(128), is_active TINYINT(1) DEFAULT '1', is_super_admin TINYINT(1) DEFAULT '0', last_login DATETIME, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX is_active_idx_idx (is_active), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ENGINE = INNODB;
CREATE TABLE sf_guard_user_group (user_id BIGINT, group_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(user_id, group_id)) ENGINE = INNODB;
CREATE TABLE sf_guard_user_permission (user_id BIGINT, permission_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(user_id, permission_id)) ENGINE = INNODB;
ALTER TABLE banner ADD CONSTRAINT banner_type_id_banner_type_id FOREIGN KEY (type_id) REFERENCES banner_type(id) ON DELETE CASCADE;
ALTER TABLE banner ADD CONSTRAINT banner_profile_id_profile_id FOREIGN KEY (profile_id) REFERENCES profile(id) ON DELETE CASCADE;
ALTER TABLE banner_click ADD CONSTRAINT banner_click_banner_id_banner_id FOREIGN KEY (banner_id) REFERENCES banner(id) ON DELETE CASCADE;
ALTER TABLE banner_region_relation ADD CONSTRAINT banner_region_relation_region_id_region_id FOREIGN KEY (region_id) REFERENCES region(id) ON DELETE CASCADE;
ALTER TABLE banner_region_relation ADD CONSTRAINT banner_region_relation_banner_id_banner_id FOREIGN KEY (banner_id) REFERENCES banner(id) ON DELETE CASCADE;
ALTER TABLE banner_view ADD CONSTRAINT banner_view_banner_id_banner_id FOREIGN KEY (banner_id) REFERENCES banner(id) ON DELETE CASCADE;
ALTER TABLE job ADD CONSTRAINT job_type_id_job_type_id FOREIGN KEY (type_id) REFERENCES job_type(id) ON DELETE CASCADE;
ALTER TABLE job ADD CONSTRAINT job_profile_id_profile_id FOREIGN KEY (profile_id) REFERENCES profile(id) ON DELETE CASCADE;
ALTER TABLE job ADD CONSTRAINT job_category_id_job_category_id FOREIGN KEY (category_id) REFERENCES job_category(id) ON DELETE CASCADE;
ALTER TABLE job_category ADD CONSTRAINT job_category_parent_id_job_category_id FOREIGN KEY (parent_id) REFERENCES job_category(id) ON DELETE CASCADE;
ALTER TABLE job_region_relation ADD CONSTRAINT job_region_relation_region_id_region_id FOREIGN KEY (region_id) REFERENCES region(id) ON DELETE CASCADE;
ALTER TABLE job_region_relation ADD CONSTRAINT job_region_relation_job_id_job_id FOREIGN KEY (job_id) REFERENCES job(id) ON DELETE CASCADE;
ALTER TABLE job_specialization ADD CONSTRAINT job_specialization_category_id_job_category_id FOREIGN KEY (category_id) REFERENCES job_category(id) ON DELETE CASCADE;
ALTER TABLE job_specialization_relation ADD CONSTRAINT jsji FOREIGN KEY (specialization_id) REFERENCES job_specialization(id);
ALTER TABLE job_specialization_relation ADD CONSTRAINT job_specialization_relation_job_id_job_id FOREIGN KEY (job_id) REFERENCES job(id) ON DELETE CASCADE;
ALTER TABLE profile ADD CONSTRAINT profile_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE profile ADD CONSTRAINT profile_type_id_profile_type_id FOREIGN KEY (type_id) REFERENCES profile_type(id) ON DELETE CASCADE;
ALTER TABLE profile ADD CONSTRAINT profile_region_id_region_id FOREIGN KEY (region_id) REFERENCES region(id) ON DELETE CASCADE;
ALTER TABLE profile ADD CONSTRAINT profile_prepayment_type_id_prepayment_type_id FOREIGN KEY (prepayment_type_id) REFERENCES prepayment_type(id) ON DELETE CASCADE;
ALTER TABLE top_job ADD CONSTRAINT top_job_job_id_job_id FOREIGN KEY (job_id) REFERENCES job(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_forgot_password ADD CONSTRAINT sf_guard_forgot_password_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_group_permission ADD CONSTRAINT sf_guard_group_permission_permission_id_sf_guard_permission_id FOREIGN KEY (permission_id) REFERENCES sf_guard_permission(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_group_permission ADD CONSTRAINT sf_guard_group_permission_group_id_sf_guard_group_id FOREIGN KEY (group_id) REFERENCES sf_guard_group(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_remember_key ADD CONSTRAINT sf_guard_remember_key_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_group ADD CONSTRAINT sf_guard_user_group_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_group ADD CONSTRAINT sf_guard_user_group_group_id_sf_guard_group_id FOREIGN KEY (group_id) REFERENCES sf_guard_group(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_permission ADD CONSTRAINT sf_guard_user_permission_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_permission ADD CONSTRAINT sf_guard_user_permission_permission_id_sf_guard_permission_id FOREIGN KEY (permission_id) REFERENCES sf_guard_permission(id) ON DELETE CASCADE;
