CREATE TABLE admin_table (id BIGINT AUTO_INCREMENT, jmeno VARCHAR(128) NOT NULL, heslo VARCHAR(128) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE pharmalink_doktor (id BIGINT AUTO_INCREMENT, kampan_id BIGINT, titul_pred VARCHAR(255), jmeno VARCHAR(255) NOT NULL, prijmeni VARCHAR(255) NOT NULL, titul_za VARCHAR(255), rc VARCHAR(255) NOT NULL, adresa VARCHAR(255) NOT NULL, mesto VARCHAR(255) NOT NULL, psc BIGINT NOT NULL, misto_narozeni VARCHAR(255), statni_obcanstvi VARCHAR(255), narodnost VARCHAR(255), stav VARCHAR(255), cislo_uctu VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, cena BIGINT, cena_slovy VARCHAR(255), dpp_pocet_hodin FLOAT(18, 2), kod VARCHAR(255), potvrzeni_datetime datetime, potvrzeni_ip VARCHAR(255), potvrzeni_kod VARCHAR(255), vytvoreno_z_admina BIGINT, rodne_prijmeni VARCHAR(255) NOT NULL, zdravotni_pojistovna VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, slug VARCHAR(255), UNIQUE INDEX pharmalink_doktor_sluggable_idx (slug), INDEX kampan_id_idx (kampan_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE pharmalink_doktor_odpoved (id BIGINT AUTO_INCREMENT, doktor_id BIGINT, odpoved_id BIGINT, otazka_id BIGINT NOT NULL, text_free VARCHAR(255), INDEX doktor_id_idx (doktor_id), INDEX odpoved_id_idx (odpoved_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE pharmalink_doktor_subodpoved (id BIGINT AUTO_INCREMENT, doktor_odpoved_id BIGINT NOT NULL, odpoved_id BIGINT NOT NULL, INDEX doktor_odpoved_id_idx (doktor_odpoved_id), INDEX odpoved_id_idx (odpoved_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE pharmalink_kampan (id BIGINT AUTO_INCREMENT, zakaznik_id BIGINT NOT NULL, nazev VARCHAR(255) NOT NULL UNIQUE, text_popis TEXT, logo VARCHAR(255), barva VARCHAR(7), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX zakaznik_id_idx (zakaznik_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE pharmalink_odpoved (id BIGINT AUTO_INCREMENT, otazka_id BIGINT NOT NULL, text_odpovedi TEXT NOT NULL, INDEX otazka_id_idx (otazka_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE pharmalink_otazka (id BIGINT AUTO_INCREMENT, kampan_id BIGINT NOT NULL, typ VARCHAR(255) DEFAULT 'radio' NOT NULL, min_odpovedi BIGINT DEFAULT 1 NOT NULL, max_odpovedi BIGINT DEFAULT 0 NOT NULL, text_otazky TEXT NOT NULL, vedlesebe TINYINT(1) DEFAULT '0' NOT NULL, INDEX kampan_id_idx (kampan_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE pharmalink_voucher (id BIGINT AUTO_INCREMENT, kampan_id BIGINT NOT NULL, kod VARCHAR(255) NOT NULL UNIQUE, popis VARCHAR(255) NOT NULL, cena BIGINT NOT NULL, cena_slovy VARCHAR(255), dpp_pocet_hodin FLOAT(18, 2) NOT NULL, INDEX kampan_id_idx (kampan_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE pharmalink_zakaznik (id BIGINT AUTO_INCREMENT, sf_guard_user_id INT, nazev VARCHAR(255) NOT NULL, text_dpp text, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX sf_guard_user_id_idx (sf_guard_user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE sf_guard_group (id INT 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_unicode_ci ENGINE = INNODB;
CREATE TABLE sf_guard_group_permission (group_id INT, permission_id INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(group_id, permission_id)) ENGINE = INNODB;
CREATE TABLE sf_guard_permission (id INT 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_unicode_ci ENGINE = INNODB;
CREATE TABLE sf_guard_remember_key (id INT AUTO_INCREMENT, user_id INT, 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, ip_address)) ENGINE = INNODB;
CREATE TABLE sf_guard_user (id INT AUTO_INCREMENT, 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_unicode_ci ENGINE = INNODB;
CREATE TABLE sf_guard_user_group (user_id INT, group_id INT, 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 INT, permission_id INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(user_id, permission_id)) ENGINE = INNODB;
ALTER TABLE pharmalink_doktor ADD CONSTRAINT pharmalink_doktor_kampan_id_pharmalink_kampan_id FOREIGN KEY (kampan_id) REFERENCES pharmalink_kampan(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_doktor_odpoved ADD CONSTRAINT pharmalink_doktor_odpoved_odpoved_id_pharmalink_odpoved_id FOREIGN KEY (odpoved_id) REFERENCES pharmalink_odpoved(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_doktor_odpoved ADD CONSTRAINT pharmalink_doktor_odpoved_doktor_id_pharmalink_doktor_id FOREIGN KEY (doktor_id) REFERENCES pharmalink_doktor(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_doktor_subodpoved ADD CONSTRAINT pharmalink_doktor_subodpoved_odpoved_id_pharmalink_odpoved_id FOREIGN KEY (odpoved_id) REFERENCES pharmalink_odpoved(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_doktor_subodpoved ADD CONSTRAINT pdpi FOREIGN KEY (doktor_odpoved_id) REFERENCES pharmalink_doktor_odpoved(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_kampan ADD CONSTRAINT pharmalink_kampan_zakaznik_id_pharmalink_zakaznik_id FOREIGN KEY (zakaznik_id) REFERENCES pharmalink_zakaznik(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_odpoved ADD CONSTRAINT pharmalink_odpoved_otazka_id_pharmalink_otazka_id FOREIGN KEY (otazka_id) REFERENCES pharmalink_otazka(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_otazka ADD CONSTRAINT pharmalink_otazka_kampan_id_pharmalink_kampan_id FOREIGN KEY (kampan_id) REFERENCES pharmalink_kampan(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_voucher ADD CONSTRAINT pharmalink_voucher_kampan_id_pharmalink_kampan_id FOREIGN KEY (kampan_id) REFERENCES pharmalink_kampan(id) ON DELETE CASCADE;
ALTER TABLE pharmalink_zakaznik ADD CONSTRAINT pharmalink_zakaznik_sf_guard_user_id_sf_guard_user_id FOREIGN KEY (sf_guard_user_id) REFERENCES sf_guard_user(id);
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;
