Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help us improve the Re-Introspection Workflow by sharing your Prisma Schema and SQL schemas 🙏 #2711

Closed
do4gr opened this issue Jun 10, 2020 · 16 comments
Labels
kind/improvement An improvement to existing feature and code. topic: re-introspection

Comments

@do4gr
Copy link
Member

do4gr commented Jun 10, 2020

Hey everyone 👋

We want to remove one of the remaining big pain points of Introspection:
If you manually adjusted your data model after introspection (to rename fields or models, or add default IDs for example) these changes are currently lost once you introspect again ("re-introspect", for example, because your database was changed manually or migrated by another tool).

It would, therefore, be a tremendous help for us if you could share your projects where you encountered this problem! The information we need is the following:

  1. Your Prisma 2 schema that you manually modified after a previous introspection
  2. Your current SQL schema which when introspected again currently leads to loss of manually added information in the Prisma 2 Schema.

Please submit your database schemas and Prisma Schemas to schemas@prisma.io.


Also, note that we're happily signing NDAs if your schemas and data models need to be treated confidently! If you like Prisma and want to see it succeed, please consider sharing your schema and data model or talking to your boss if that's needed to be able to share your information! 🙂


Thanks for helping us making Prisma better 🙌

@do4gr do4gr added kind/improvement An improvement to existing feature and code. topic: re-introspection labels Jun 10, 2020
@do4gr do4gr pinned this issue Jun 10, 2020
@janpio janpio changed the title **Help us improve the Re-Introspection Workflow by sharing your Prisma Schema and SQL schemas 🙏** Help us improve the Re-Introspection Workflow by sharing your Prisma Schema and SQL schemas 🙏 Jun 10, 2020
@Akxe
Copy link
Contributor

Akxe commented Jun 10, 2020

Thank you, this is an awesome initiative. My SQL is huge, I will happily give it to you, but for simplicity, I will also sum up what I need to do now and what I would like to do, but due to the size am unable.

I am now just testing the framework with nexus-prisma, thus I only use 5 tables of this monstrosity (namely: Cart, CartItems, nosice, odbobi and osoby)

My database is due to its age and an old program (in Delphi) still in our native language. To make it worst a lot of columns are not very vel named, as 3 characters shortcuts were seen as the best approach.

What I do after every introspection:

  • Rename 2 enums with same values to one (dokMena & zMena)
  • Fix the enumvalues (enum('Kč','€','c€'))
  • Fix names of relations 'obdobi_Cart_startPeriodIDToobdobi' => 'PeriodEnd' and 'obdobi_Cart_endPeriodIDToobdobi' => 'PeriodStart'

What I would like to do

  • Rename all tables and columns to English (and correct plural/singular)
    • I want this so that I can expose it via nexus-prisma easily.
    • And for other developers so they are less confused when they see my code.

dumb.sql
-- Server version	8.0.18

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /;
/
!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/
!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/
!50503 SET NAMES utf8 /;
/
!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE /;
/
!40103 SET TIME_ZONE='+00:00' /;
/
!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 /;
/
!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 /;
/
!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' /;
/
!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table Cart

DROP TABLE IF EXISTS Cart;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE Cart (
cartID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
email varchar(45) COLLATE cp1250_czech_cs NOT NULL,
startPeriodID smallint(5) unsigned NOT NULL,
endPeriodID smallint(5) unsigned NOT NULL,
assignedTo smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (cartID),
KEY cartAssignement_idx (assignedTo),
KEY cartPeriodEnd_idx (endPeriodID),
KEY cartPeriodStart_idx (startPeriodID),
CONSTRAINT cartAssignement FOREIGN KEY (assignedTo) REFERENCES osoby (idOsoby) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT cartPeriodEnd FOREIGN KEY (endPeriodID) REFERENCES obdobi (idObdobi),
CONSTRAINT cartPeriodStart FOREIGN KEY (startPeriodID) REFERENCES obdobi (idObdobi)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table CartItem

DROP TABLE IF EXISTS CartItem;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE CartItem (
cartID smallint(5) unsigned NOT NULL,
NCis int(11) NOT NULL,
PRIMARY KEY (cartID,NCis),
KEY cartCarrier_idx (NCis),
CONSTRAINT cartCarrier FOREIGN KEY (NCis) REFERENCES nosice (NCis) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT cartItem FOREIGN KEY (cartID) REFERENCES Cart (cartID) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table adresy

DROP TABLE IF EXISTS adresy;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE adresy (
idAdr smallint(5) unsigned NOT NULL AUTO_INCREMENT,
idFirmy smallint(5) unsigned NOT NULL,
aOdd varchar(120) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
aUlice varchar(120) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
aMesto varchar(80) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
aPSC varchar(10) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
aStat varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
aPozn varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (idAdr),
KEY key_idx (idFirmy),
CONSTRAINT adr_firma FOREIGN KEY (idFirmy) REFERENCES firmy (idFirmy) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=581 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table alarm

DROP TABLE IF EXISTS alarm;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE alarm (
idAlarm smallint(5) unsigned NOT NULL AUTO_INCREMENT,
dAlarm date DEFAULT NULL,
dUdalost date DEFAULT NULL,
Udalost varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
ks smallint(6) DEFAULT NULL,
idZak smallint(5) unsigned DEFAULT NULL,
idOsoby smallint(5) unsigned DEFAULT NULL,
MyFirma tinyint(4) DEFAULT NULL,
aTyp tinyint(4) DEFAULT NULL,
aStav tinyint(4) DEFAULT NULL,
PRIMARY KEY (idAlarm),
KEY dAlarm (dAlarm),
KEY zakazka_idx (idZak),
KEY alarm_osoba_idx (idOsoby),
CONSTRAINT alarm_osoba FOREIGN KEY (idOsoby) REFERENCES osoby (idOsoby),
CONSTRAINT alarm_zakazka FOREIGN KEY (idZak) REFERENCES zakazky (idZak)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table audit

DROP TABLE IF EXISTS audit;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE audit (
ncis int(11) NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
aDatum date NOT NULL,
aOsoba smallint(5) unsigned NOT NULL,
audit text NOT NULL,
PRIMARY KEY (ncis,idObdobi),
KEY obdobi (idObdobi),
KEY osoba_idx (aOsoba),
CONSTRAINT nosice FOREIGN KEY (ncis) REFERENCES nosice (NCis),
CONSTRAINT obdobi FOREIGN KEY (idObdobi) REFERENCES obdobi (idObdobi),
CONSTRAINT osoba FOREIGN KEY (aOsoba) REFERENCES osoby (idOsoby) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table auditnos

DROP TABLE IF EXISTS auditnos;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE auditnos (
idAudit int(11) NOT NULL AUTO_INCREMENT,
ncis int(11) NOT NULL,
idKlient smallint(5) unsigned NOT NULL,
aDatum date NOT NULL,
aStav enum('OK','Vada','Urgentní') COLLATE cp1250_czech_cs NOT NULL,
Audit text COLLATE cp1250_czech_cs NOT NULL,
PRIMARY KEY (idAudit),
KEY ncis (ncis) /
!80000 INVISIBLE /,
KEY aDatum (aDatum) /
!80000 INVISIBLE /,
KEY auditnos (ncis,aDatum,idKlient) /
!80000 INVISIBLE /,
KEY auditnos_klient_idx (idKlient),
CONSTRAINT aditnos_nos FOREIGN KEY (ncis) REFERENCES nosice (NCis),
CONSTRAINT auditnos_klient FOREIGN KEY (idKlient) REFERENCES firmy (idFirmy)
) ENGINE=InnoDB AUTO_INCREMENT=65535 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table auditprod

DROP TABLE IF EXISTS auditprod;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE auditprod (
idProd smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
aDatum date DEFAULT NULL,
Audit text CHARACTER SET cp1250 COLLATE cp1250_czech_cs,
PRIMARY KEY (idProd,idObdobi)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table dir

DROP TABLE IF EXISTS dir;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE dir (
idDir smallint(5) unsigned NOT NULL AUTO_INCREMENT,
dir varchar(255) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
dirPrim tinyint(4) DEFAULT NULL,
dirPopis varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (idDir),
KEY dir (dir)
) ENGINE=InnoDB AUTO_INCREMENT=1126 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table dokumenty

DROP TABLE IF EXISTS dokumenty;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE dokumenty (
idDok smallint(6) unsigned NOT NULL AUTO_INCREMENT,
dokTyp tinyint(4) DEFAULT NULL COMMENT 'smer dokumentu \n0 - klientsky generovany\n1 - klientsky ze souboru (nebo bez souboru)\n2 - dodavatelsky\n3 - dodavatele Ahold - multi zak\n',
dokDruh char(3) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL COMMENT 'typ dokumentu orientacne\nRS - ramcova smlouva Ors - Objednavka k RS\nObj - objednavka Sml - smlouva\nPrl - priloha smlouvy Dod - dodatek\nDD - dodavatelsky dokument Svo - svo\nZak - zakaznicka smlouva',
dokFirma smallint(5) unsigned NOT NULL DEFAULT '1',
dokFakt char(1) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL COMMENT 'nic - nefakturuje se\nA - ano - fakturační dokument připravený - nemá vygenerované faktury\nP - připravené faktury - ještě se nefakturuje\nF - fakturace probíhá\nU - ukončená fakturace',
dokCislo varchar(12) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
dokKCislo varchar(12) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL COMMENT 'klientske cislo dokumentu (ne nase) ',
dokNazev varchar(120) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
idDir smallint(5) unsigned NOT NULL DEFAULT '2',
idFirmy smallint(5) unsigned NOT NULL,
idKlient smallint(5) unsigned DEFAULT NULL,
idZak smallint(5) unsigned DEFAULT NULL,
idOsoby smallint(5) unsigned DEFAULT NULL,
idAdrKP smallint(5) unsigned DEFAULT NULL,
dokOd date DEFAULT NULL,
dokDo date DEFAULT NULL,
dokDPodpis date DEFAULT NULL,
dokNeurcita enum('neurčitá','AP','opce') COLLATE cp1250_czech_cs DEFAULT NULL COMMENT '0 - určitá\n1 - ''neurčitá'',\n2 - ''AP'',\n3- ''opce''',
dokVypMes tinyint(4) DEFAULT NULL,
dokSeznam tinyint(4) DEFAULT NULL COMMENT 'bool \nobsahuje seznam ploch = konecny dokument',
idDokNad smallint(5) unsigned DEFAULT NULL COMMENT 'Nadrizeny dokument - napr. Ramcova smlouva\n',
dokPDF tinyint(4) NOT NULL DEFAULT '0',
dokPrac tinyint(4) DEFAULT NULL,
dokExt varchar(10) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
dokCCena float DEFAULT NULL,
dokMena enum('Kč','€','c€') CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL DEFAULT 'Kč',
PRIMARY KEY (idDok),
KEY doc_dir_idx (idDir),
KEY doc_firma_idx (idFirmy),
KEY doc_klient_idx (idKlient),
KEY doc_zadavatel_idx (dokFirma),
KEY doc_zak_idx (idZak),
KEY doc_osoba_idx (idOsoby),
KEY doc_adr_idx (idAdrKP),
CONSTRAINT doc_adr FOREIGN KEY (idAdrKP) REFERENCES adresy (idAdr),
CONSTRAINT doc_dir FOREIGN KEY (idDir) REFERENCES dir (idDir),
CONSTRAINT doc_firma FOREIGN KEY (idFirmy) REFERENCES firmy (idFirmy),
CONSTRAINT doc_klient FOREIGN KEY (idKlient) REFERENCES firmy (idFirmy),
CONSTRAINT doc_osoba FOREIGN KEY (idOsoby) REFERENCES osoby (idOsoby),
CONSTRAINT doc_zadavatel FOREIGN KEY (dokFirma) REFERENCES firmy (idFirmy),
CONSTRAINT doc_zak FOREIGN KEY (idZak) REFERENCES zakazky (idZak) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3956 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table firmy

DROP TABLE IF EXISTS firmy;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE firmy (
idFirmy smallint(5) unsigned NOT NULL,
FFirma varchar(50) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
FNazev varchar(120) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
ICO varchar(12) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
DIC varchar(15) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Splatnost tinyint(4) DEFAULT '14',
Frekvence tinyint(4) DEFAULT '-1',
fTel varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
fFax varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
fPozn varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
fSoud varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
idPrimKontakt smallint(5) unsigned DEFAULT NULL,
idZastoupena smallint(6) unsigned DEFAULT NULL,
idLepic smallint(5) unsigned DEFAULT NULL,
idFirAdr smallint(5) unsigned DEFAULT NULL,
idKorespAdr smallint(5) unsigned DEFAULT NULL,
idLepicAdr smallint(5) unsigned DEFAULT NULL,
idkDir smallint(5) unsigned DEFAULT NULL,
fKlient tinyint(4) NOT NULL DEFAULT '0',
fDodav tinyint(4) NOT NULL DEFAULT '0',
fRSdod tinyint(4) NOT NULL DEFAULT '0',
fAktivni tinyint(4) NOT NULL DEFAULT '1',
Cinnost varchar(250) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Region varchar(500) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
fKat enum('Politika','Alkohol','Potraviny','Nábytek','Sex','Kasino','ostatní') COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (idFirmy),
KEY firma_adr_idx (idKorespAdr),
KEY firma_lepard_idx (idLepicAdr),
KEY firma_dir_idx (idkDir),
KEY firma_adr_idx1 (idFirAdr),
CONSTRAINT firma_adr FOREIGN KEY (idFirAdr) REFERENCES adresy (idAdr),
CONSTRAINT firma_dir FOREIGN KEY (idkDir) REFERENCES dir (idDir),
CONSTRAINT firma_koradr FOREIGN KEY (idKorespAdr) REFERENCES adresy (idAdr),
CONSTRAINT firma_lepard FOREIGN KEY (idLepicAdr) REFERENCES adresy (idAdr)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table fotoaudit

DROP TABLE IF EXISTS fotoaudit;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE fotoaudit (
idAudit int(11) NOT NULL,
Verze tinyint(4) NOT NULL,
fName varchar(200) COLLATE cp1250_czech_cs NOT NULL,
PRIMARY KEY (idAudit,Verze),
CONSTRAINT foto_audit FOREIGN KEY (idAudit) REFERENCES auditnos (idAudit)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table fotodoc

DROP TABLE IF EXISTS fotodoc;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE fotodoc (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
nCis int(11) NOT NULL,
idSkup smallint(5) unsigned DEFAULT NULL,
verze tinyint(4) NOT NULL,
fName varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
UNIQUE KEY idZak_UNIQUE (idZak,idObdobi,nCis,idSkup,verze),
KEY ncis & obdobi & idZak (idZak,nCis,idObdobi),
KEY fotodoc_skupina (idSkup),
CONSTRAINT fotodoc_skupina FOREIGN KEY (idSkup) REFERENCES skupiny (idSkup),
CONSTRAINT fotodoc_zaknos FOREIGN KEY (idZak, idObdobi, nCis) REFERENCES zaknos (idZak, idObdobi, ncis) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table fotogr

DROP TABLE IF EXISTS fotogr;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE fotogr (
ncis int(11) NOT NULL,
idZak smallint(5) unsigned NOT NULL,
fname varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (ncis,idZak),
CONSTRAINT grafika_zakazkyp FOREIGN KEY (ncis, idZak) REFERENCES zakazkyp (NCis, idZak)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table fotomapy

DROP TABLE IF EXISTS fotomapy;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE fotomapy (
nCis int(11) NOT NULL,
verze tinyint(4) NOT NULL AUTO_INCREMENT,
fName varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
PRIMARY KEY (verze,nCis),
KEY fotomapy_nosic_idx (nCis),
CONSTRAINT fotomapy_nosic FOREIGN KEY (nCis) REFERENCES nosice (NCis)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table fotoprod

DROP TABLE IF EXISTS fotoprod;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE fotoprod (
idProd smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
fName varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
PRIMARY KEY (idProd,idObdobi),
KEY fotoprod_obdobi (idObdobi),
CONSTRAINT foto_prod FOREIGN KEY (idProd) REFERENCES prodejny (idProd),
CONSTRAINT fotoprod_obdobi FOREIGN KEY (idObdobi) REFERENCES obdobi (idObdobi)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table fotorl

DROP TABLE IF EXISTS fotorl;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE fotorl (
nCis int(11) NOT NULL,
verze tinyint(4) NOT NULL AUTO_INCREMENT,
fName varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
PRIMARY KEY (verze,nCis),
KEY nCis (nCis),
CONSTRAINT fotorl_nosic FOREIGN KEY (nCis) REFERENCES nosice (NCis)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table jmena

DROP TABLE IF EXISTS jmena;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE jmena (
idJmena smallint(5) unsigned NOT NULL AUTO_INCREMENT,
idFirmy smallint(5) unsigned NOT NULL,
Titul varchar(10) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT '',
Jmeno varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT '',
Prijmeni varchar(80) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
email varchar(150) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
tel varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
jPozn varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
jednatel tinyint(4) DEFAULT NULL,
kontakt tinyint(4) DEFAULT NULL,
PRIMARY KEY (idJmena),
KEY jmeno_firma_idx (idFirmy),
CONSTRAINT jmeno_firma FOREIGN KEY (idFirmy) REFERENCES firmy (idFirmy)
) ENGINE=InnoDB AUTO_INCREMENT=699 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table kategorie

DROP TABLE IF EXISTS kategorie;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE kategorie (
idKat smallint(5) unsigned NOT NULL,
Kategorie varchar(45) COLLATE cp1250_czech_cs NOT NULL,
kZakl tinyint(4) DEFAULT NULL,
kBarva int(11) DEFAULT NULL,
hex varchar(7) COLLATE cp1250_czech_cs GENERATED ALWAYS AS (concat(_utf8mb4'#',lpad(convert(hex(((((kBarva & 0xff) << 16) | ((kBarva & 0xff0000) >> 16)) | (kBarva & 0x00ff00))) using utf8mb4),6,_utf8mb4'0'))) STORED NOT NULL,
PRIMARY KEY (idKat),
UNIQUE KEY Skupina_UNIQUE (Kategorie)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table korporace

DROP TABLE IF EXISTS korporace;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE korporace (
idKlient smallint(5) unsigned NOT NULL,
KorpNazev varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
korpFirma smallint(5) unsigned DEFAULT NULL,
delkaObdobi tinyint(4) DEFAULT NULL,
delkaObdobiAudit tinyint(4) DEFAULT NULL,
idObdobi1 smallint(5) unsigned DEFAULT NULL,
idObdobiAudit1 smallint(5) unsigned DEFAULT NULL,
otyp char(1) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
otypaudit char(1) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
idLogo smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (idKlient),
KEY korp_logo_idx (idLogo),
KEY korp_obdobi (idObdobi1),
KEY auditkorp_obdobi_idx (idObdobiAudit1),
KEY korp_firma_idx (korpFirma),
CONSTRAINT auditkorp_obdobi FOREIGN KEY (idObdobiAudit1) REFERENCES obdobi (idObdobi),
CONSTRAINT korp_firma FOREIGN KEY (korpFirma) REFERENCES firmy (idFirmy),
CONSTRAINT korp_logo FOREIGN KEY (idLogo) REFERENCES loga (idLogo),
CONSTRAINT korp_obdobi FOREIGN KEY (idObdobi1) REFERENCES obdobi (idObdobi)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table korposoby

DROP TABLE IF EXISTS korposoby;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE korposoby (
idKorpOsoby smallint(5) unsigned NOT NULL AUTO_INCREMENT,
Funkce enum('admin','GL','VL','GF','VKL','VP') CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
level tinyint(4) unsigned NOT NULL,
Jmeno varchar(40) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Prijmeni varchar(45) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
Heslo char(32) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
idNad smallint(5) unsigned DEFAULT NULL,
idProd smallint(5) unsigned DEFAULT NULL,
hashInc tinyint(4) unsigned NOT NULL DEFAULT '0',
idKlient smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (idKorpOsoby),
UNIQUE KEY Prijmeni_UNIQUE (Prijmeni),
KEY idNad (idNad),
KEY idProd (idProd),
KEY korpOsoby_klient_idx (idKlient),
CONSTRAINT korpOsoby_klient FOREIGN KEY (idKlient) REFERENCES firmy (idFirmy),
CONSTRAINT korpOsoby_nadrizeny FOREIGN KEY (idNad) REFERENCES korposoby (idKorpOsoby),
CONSTRAINT korpOsoby_prod FOREIGN KEY (idProd) REFERENCES prodejny (idProd)
) ENGINE=InnoDB AUTO_INCREMENT=214 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table kraj

DROP TABLE IF EXISTS kraj;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE kraj (
idKraj tinyint(3) unsigned NOT NULL,
Kraj varchar(45) NOT NULL,
PRIMARY KEY (idKraj)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table kraje

DROP TABLE IF EXISTS kraje;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE kraje (
idKr tinyint(3) unsigned DEFAULT NULL,
XKraj varchar(56) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
Kraj varchar(25) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
KEY index1 (idKr),
CONSTRAINT krajalias_kraj FOREIGN KEY (idKr) REFERENCES kraj (idKraj)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table loga

DROP TABLE IF EXISTS loga;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE loga (
idLogo smallint(5) unsigned NOT NULL AUTO_INCREMENT,
idKlient smallint(5) unsigned DEFAULT NULL,
Logo varchar(45) DEFAULT NULL,
Soubor varchar(80) DEFAULT NULL,
skupina enum('potraviny','nábytek','hobby') DEFAULT NULL,
PRIMARY KEY (idLogo),
KEY Logo (Logo),
KEY logo_klient_idx (idKlient),
CONSTRAINT logo_klient FOREIGN KEY (idKlient) REFERENCES firmy (idFirmy)
) ENGINE=InnoDB AUTO_INCREMENT=133 DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table mapperitem

DROP TABLE IF EXISTS mapperitem;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE mapperitem (
idMapper smallint(5) unsigned NOT NULL,
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
color int(11) NOT NULL,
hex varchar(7) COLLATE cp1250_czech_cs GENERATED ALWAYS AS (concat(_utf8mb4'#',lpad(convert(hex(((((color & 0xff) << 16) | ((color & 0xff0000) >> 16)) | (color & 0x00ff00))) using utf8mb4),6,_utf8mb4'0'))) STORED NOT NULL,
PRIMARY KEY (idMapper,idZak),
KEY mapper_zakobdobi_idx (idZak,idObdobi),
CONSTRAINT mapper_parent FOREIGN KEY (idMapper) REFERENCES mappername (idMapper),
CONSTRAINT mapper_zakobdobi FOREIGN KEY (idZak, idObdobi) REFERENCES zakobdobi (idZak, idObdobi)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table mappername

DROP TABLE IF EXISTS mappername;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE mappername (
idMapper smallint(5) unsigned NOT NULL AUTO_INCREMENT,
Name varchar(50) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
idOsoby smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (idMapper),
KEY mapper_osoba_idx (idOsoby),
CONSTRAINT mapper_osoba FOREIGN KEY (idOsoby) REFERENCES osoby (idOsoby)
) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table miniprod

DROP TABLE IF EXISTS miniprod;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE miniprod (
idMiniprod int(11) unsigned NOT NULL AUTO_INCREMENT,
idLogo smallint(5) unsigned NOT NULL,
lat float NOT NULL DEFAULT '0',
lng float NOT NULL DEFAULT '0',
PRIMARY KEY (idMiniprod),
KEY Logo_idx (idLogo),
CONSTRAINT MiniProd_Loga FOREIGN KEY (idLogo) REFERENCES loga (idLogo) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=3939 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs COMMENT='Mini prodejny\nProdejna, která má jen pozici a logo, je to rodič pro velké prodejny, pro které děláme audity';
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table motivy

DROP TABLE IF EXISTS motivy;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE motivy (
Motiv smallint(5) unsigned NOT NULL AUTO_INCREMENT,
mText varchar(60) NOT NULL,
mBarva bigint(20) NOT NULL,
mTyp char(1) DEFAULT NULL,
midZak smallint(5) unsigned DEFAULT '0',
mSkup enum('Kam','Nav','SVO') DEFAULT NULL,
mZkratka varchar(4) DEFAULT NULL,
mZakl tinyint(4) DEFAULT NULL,
idKat smallint(5) unsigned NOT NULL DEFAULT '1',
hex varchar(7) GENERATED ALWAYS AS (concat(_utf8mb4'#',lpad(convert(hex(((((mBarva & 0xff) << 16) | ((mBarva & 0xff0000) >> 16)) | (mBarva & 0x00ff00))) using utf8mb4),6,_utf8mb4'0'))) STORED NOT NULL,
PRIMARY KEY (Motiv),
KEY motiv_idZak_idx (midZak),
CONSTRAINT motiv_idZak FOREIGN KEY (midZak) REFERENCES zakazky (idZak) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3184 DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table myfirmy

DROP TABLE IF EXISTS myfirmy;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE myfirmy (
idMyFirmy tinyint(4) NOT NULL,
mfNazev varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
mfICO varchar(15) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
mfUlice varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
mfMesto varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
mfPsc varchar(6) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
mfJednatel smallint(6) DEFAULT NULL,
mfPohRada varchar(12) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
mfPohmServer varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
mfKursEur float DEFAULT NULL,
idDod smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (idMyFirmy)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nabidka

DROP TABLE IF EXISTS nabidka;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nabidka (
Cis int(11) NOT NULL,
idOsoby smallint(5) unsigned NOT NULL,
X tinyint(4) DEFAULT NULL,
PRIMARY KEY (Cis,idOsoby)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nabzak

DROP TABLE IF EXISTS nabzak;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nabzak (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
ncis int(11) NOT NULL,
obsaz char(2) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
X tinyint(4) DEFAULT NULL,
PRIMARY KEY (idZak,ncis,idObdobi),
KEY nabzak_zaknos (idZak,idObdobi,ncis),
CONSTRAINT nabzak_zaknos FOREIGN KEY (idZak, idObdobi, ncis) REFERENCES zaknos (idZak, idObdobi, ncis) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nadobdobi

DROP TABLE IF EXISTS nadobdobi;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nadobdobi (
idKlient smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
noTyp enum('m','A') CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL DEFAULT 'm',
PRIMARY KEY (idKlient,idObdobi),
KEY nadbodobi_obdobi (idObdobi),
CONSTRAINT nadbodobi_obdobi FOREIGN KEY (idObdobi) REFERENCES obdobi (idObdobi),
CONSTRAINT nadobdobi_klient FOREIGN KEY (idKlient) REFERENCES firmy (idFirmy)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nosdok

DROP TABLE IF EXISTS nosdok;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nosdok (
idDok smallint(6) unsigned NOT NULL,
ncis int(11) NOT NULL,
PRIMARY KEY (idDok,ncis),
KEY nosdok_nos_idx (ncis),
CONSTRAINT nosdok_dok FOREIGN KEY (idDok) REFERENCES dokumenty (idDok),
CONSTRAINT nosdok_nos FOREIGN KEY (ncis) REFERENCES nosice (NCis)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nosice

DROP TABLE IF EXISTS nosice;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nosice (
NCis int(11) NOT NULL,
Zdroj char(1) DEFAULT NULL,
idDod smallint(5) unsigned DEFAULT NULL,
Typ char(1) DEFAULT NULL,
Mesto varchar(80) DEFAULT NULL,
Ulice varchar(80) DEFAULT NULL,
Popis varchar(100) DEFAULT NULL,
Velikost varchar(20) DEFAULT NULL,
idKraj tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'idKraj 0 == ""',
VCis varchar(20) DEFAULT NULL,
Poloha tinyint(4) DEFAULT NULL,
Osvetleni tinyint(4) DEFAULT NULL,
Videt tinyint(4) DEFAULT NULL,
NPozn varchar(500) DEFAULT NULL,
lng double DEFAULT NULL,
lat double DEFAULT NULL,
Azimut smallint(6) DEFAULT '-1',
GpsNase tinyint(4) DEFAULT '0',
TextNase tinyint(4) DEFAULT '0',
Prujezd int(11) DEFAULT NULL,
Plocha float DEFAULT NULL,
kVel tinyint(4) DEFAULT NULL,
kPol tinyint(4) DEFAULT NULL,
kOsv tinyint(4) DEFAULT NULL,
kVid tinyint(4) DEFAULT NULL,
kExkl tinyint(4) DEFAULT NULL,
kOkolo tinyint(4) DEFAULT NULL,
PRIMARY KEY (NCis),
KEY nosic_dodavatel_idx (idDod),
KEY nosic_kraj_idx (idKraj),
CONSTRAINT nosic_dodavatel FOREIGN KEY (idDod) REFERENCES firmy (idFirmy),
CONSTRAINT nosic_kraj FOREIGN KEY (idKraj) REFERENCES kraj (idKraj)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nosiceex

DROP TABLE IF EXISTS nosiceex;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nosiceex (
ncis int(11) NOT NULL,
exRezervace tinyint(4) DEFAULT '0',
exNCena int(11) DEFAULT NULL,
exPolitika tinyint(4) DEFAULT NULL,
exPotraviny tinyint(4) DEFAULT NULL,
exNabytek tinyint(4) DEFAULT NULL,
exSex tinyint(4) DEFAULT NULL,
exAlkohol tinyint(4) DEFAULT NULL,
exKasino tinyint(4) DEFAULT NULL,
PRIMARY KEY (ncis),
CONSTRAINT ex_nosic FOREIGN KEY (ncis) REFERENCES nosice (NCis)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nosprod

DROP TABLE IF EXISTS nosprod;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nosprod (
ncis int(11) NOT NULL,
idProd smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
podil tinyint(4) DEFAULT '1',
PRIMARY KEY (ncis,idProd,idObdobi),
KEY nosobd (ncis,idObdobi),
KEY nosprod_prod_idx (idProd),
KEY nosprod_obdobi (idObdobi),
CONSTRAINT nosprod_ncis FOREIGN KEY (ncis) REFERENCES nosice (NCis),
CONSTRAINT nosprod_obdobi FOREIGN KEY (idObdobi) REFERENCES obdobi (idObdobi),
CONSTRAINT nosprod_prod FOREIGN KEY (idProd) REFERENCES prodejny (idProd)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nosskup

DROP TABLE IF EXISTS nosskup;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nosskup (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
ncis int(11) NOT NULL,
idSkup smallint(5) unsigned NOT NULL,
idMotiv smallint(5) unsigned NOT NULL,
produkce tinyint(4) DEFAULT NULL,
nsPozn varchar(80) COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (idObdobi,ncis,idSkup,idZak),
KEY idSkup (idSkup),
KEY nosskup_motiv (idMotiv),
KEY zaknos (idZak,idObdobi,idSkup),
KEY nosskup_zaknos (idZak,idObdobi,ncis),
CONSTRAINT nosskup_motiv FOREIGN KEY (idMotiv) REFERENCES motivy (Motiv),
CONSTRAINT nosskup_skupina FOREIGN KEY (idSkup) REFERENCES skupiny (idSkup),
CONSTRAINT nosskup_zaknos FOREIGN KEY (idZak, idObdobi, ncis) REFERENCES zaknos (idZak, idObdobi, ncis)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table nosvyb

DROP TABLE IF EXISTS nosvyb;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE nosvyb (
NCis int(11) NOT NULL,
typKamp char(3) COLLATE cp1250_czech_cs NOT NULL,
vybrano int(5) unsigned NOT NULL DEFAULT '0',
nevybrano int(5) GENERATED ALWAYS AS ((celkem - vybrano)) VIRTUAL,
celkem int(6) unsigned NOT NULL DEFAULT '0',
cetnost float GENERATED ALWAYS AS ((vybrano / celkem)) VIRTUAL,
PRIMARY KEY (NCis,typKamp),
CONSTRAINT vyb_nosic FOREIGN KEY (NCis) REFERENCES nosice (NCis)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs COMMENT='Informace o výberech nosiče';
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table obdobi

DROP TABLE IF EXISTS obdobi;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE obdobi (
idObdobi smallint(5) unsigned NOT NULL AUTO_INCREMENT,
od date NOT NULL,
do date NOT NULL,
otyp char(1) NOT NULL DEFAULT 'o',
Obdobi varchar(45) GENERATED ALWAYS AS (if((otyp = _cp1250'm'),convert(date_format(od,_utf8mb4'%c/%Y') using utf8mb4),concat(convert(date_format(od,_utf8mb4'%c/%Y') using utf8mb4),_utf8mb4' - ',convert(date_format(do,_utf8mb4'%c/%Y') using utf8mb4)))) STORED NOT NULL,
delka tinyint(4) GENERATED ALWAYS AS ((((12 * (year(do) - year(od))) + (month(do) - month(od))) + 1)) STORED NOT NULL,
RM smallint(6) GENERATED ALWAYS AS (if((otyp = _cp1250'm'),((12 * year(od)) + month(od)),NULL)) VIRTUAL,
PRIMARY KEY (idObdobi),
UNIQUE KEY Datumy (od,do,otyp)
) ENGINE=InnoDB AUTO_INCREMENT=187 DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table osoby

DROP TABLE IF EXISTS osoby;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE osoby (
idOsoby smallint(5) unsigned NOT NULL AUTO_INCREMENT,
Alias varchar(20) NOT NULL,
Jmeno varchar(45) DEFAULT NULL,
Prava tinyint(4) DEFAULT '3',
Email varchar(100) DEFAULT NULL,
Tel varchar(20) DEFAULT NULL,
Heslo varchar(45) DEFAULT NULL,
Jednatel tinyint(4) DEFAULT NULL,
Podpis mediumblob,
PRIMARY KEY (idOsoby),
UNIQUE KEY Alias_UNIQUE (Alias)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table print

DROP TABLE IF EXISTS print;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE print (
idPrint int(11) NOT NULL AUTO_INCREMENT COMMENT 'urcuje poradi v seznamu',
idOsoby smallint(6) DEFAULT NULL,
ncis int(11) DEFAULT NULL,
PRIMARY KEY (idPrint)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table prodejny

DROP TABLE IF EXISTS prodejny;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE prodejny (
idProd smallint(5) unsigned NOT NULL,
Prodejna varchar(60) NOT NULL,
idMiniprod int(10) unsigned DEFAULT NULL,
PKod int(5) unsigned NOT NULL,
PTyp char(2) DEFAULT NULL,
Mesto varchar(60) DEFAULT NULL,
Ulice varchar(80) DEFAULT NULL,
PSC varchar(6) DEFAULT NULL,
idKraj tinyint(3) unsigned DEFAULT NULL,
idKlient smallint(5) unsigned NOT NULL,
PPozn text,
PRIMARY KEY (idProd),
KEY prod_kraj_idx (idKraj),
KEY prod_klient_idx (idKlient),
CONSTRAINT prod_klient FOREIGN KEY (idKlient) REFERENCES firmy (idFirmy),
CONSTRAINT prod_kraj FOREIGN KEY (idKraj) REFERENCES kraj (idKraj)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COMMENT='Prodejna, dědí logo a pozici z mini prodejny';
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table produkce

DROP TABLE IF EXISTS produkce;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE produkce (
idProdukce smallint(6) NOT NULL,
prZkratka varchar(30) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
prNazev varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (idProdukce)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table prujezd

DROP TABLE IF EXISTS prujezd;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE prujezd (
idprujezd int(11) NOT NULL AUTO_INCREMENT,
prujezd int(11) NOT NULL COMMENT 'Prujezdnost v daném bodě',
lat float NOT NULL,
lng float NOT NULL,
PRIMARY KEY (idprujezd)
) ENGINE=InnoDB AUTO_INCREMENT=4418 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table rezervace

DROP TABLE IF EXISTS rezervace;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE rezervace (
idRez smallint(5) unsigned NOT NULL AUTO_INCREMENT,
idKlient smallint(6) unsigned DEFAULT NULL,
idOsoby smallint(5) unsigned DEFAULT NULL,
RZkratka varchar(10) DEFAULT NULL,
RPopis varchar(80) DEFAULT NULL,
RStav char(1) DEFAULT NULL,
RRok smallint(6) DEFAULT NULL,
RMesic tinyint(4) DEFAULT NULL,
RDelka tinyint(4) DEFAULT NULL,
DKonec date DEFAULT NULL,
DPrac datetime DEFAULT NULL,
idZak smallint(5) unsigned DEFAULT '0',
Email2 varchar(100) DEFAULT '',
PRIMARY KEY (idRez)
) ENGINE=InnoDB AUTO_INCREMENT=740 DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table rezervacep

DROP TABLE IF EXISTS rezervacep;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE rezervacep (
idRez smallint(5) unsigned NOT NULL,
NCis int(11) NOT NULL,
Rok smallint(6) NOT NULL,
Mesic tinyint(4) NOT NULL,
RPoradi tinyint(4) NOT NULL DEFAULT '1',
RM smallint(6) GENERATED ALWAYS AS (((12 * Rok) + Mesic)) VIRTUAL,
PRIMARY KEY (idRez,NCis,Rok,Mesic),
KEY rez_ncis_idx (NCis),
CONSTRAINT nos_rez FOREIGN KEY (idRez) REFERENCES rezervace (idRez),
CONSTRAINT rez_ncis FOREIGN KEY (NCis) REFERENCES nosice (NCis)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table rsnosice

DROP TABLE IF EXISTS rsnosice;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE rsnosice (
ncis int(11) NOT NULL,
idDod smallint(5) unsigned NOT NULL,
Mesto varchar(80) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Ctvrt varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Ulice varchar(101) CHARACTER SET cp1250 COLLATE cp1250_general_ci DEFAULT NULL,
Popis varchar(100) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Kraj varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Velikost varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Poloha tinyint(4) DEFAULT NULL,
Osvetleni tinyint(4) DEFAULT NULL,
Videt tinyint(4) DEFAULT NULL,
lng double DEFAULT NULL,
lat double DEFAULT NULL,
stav tinyint(3) NOT NULL,
typ char(1) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
tvelikost varchar(45) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
idKraj tinyint(3) unsigned DEFAULT NULL,
PRIMARY KEY (ncis),
KEY rsnos_dod_idx (idDod),
KEY rsnos_kraj_idx (idKraj),
CONSTRAINT rsnos_dod FOREIGN KEY (idDod) REFERENCES firmy (idFirmy),
CONSTRAINT rsnos_kraj FOREIGN KEY (idKraj) REFERENCES kraj (idKraj),
CONSTRAINT rsnos_nos FOREIGN KEY (ncis) REFERENCES nosice (NCis)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table skupiny

DROP TABLE IF EXISTS skupiny;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE skupiny (
idZak smallint(5) unsigned NOT NULL COMMENT 'Null - Obecná skupina (barva)\\nid - Přiřazená a pouze pro danou zakázku',
idSkup smallint(5) unsigned NOT NULL AUTO_INCREMENT,
idKat smallint(5) unsigned NOT NULL,
Skupina varchar(45) COLLATE cp1250_czech_cs NOT NULL,
sBarva int(11) NOT NULL,
hex varchar(7) COLLATE cp1250_czech_cs GENERATED ALWAYS AS (concat(_utf8mb4'#',lpad(convert(hex(((((sBarva & 0xff) << 16) | ((sBarva & 0xff0000) >> 16)) | (sBarva & 0x00ff00))) using utf8mb4),6,_utf8mb4'0'))) STORED NOT NULL,
PRIMARY KEY (idSkup,idZak)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table svo

DROP TABLE IF EXISTS svo;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE svo (
ncis int(11) NOT NULL,
svoPozice enum('pravá','střed','levá','záda pravá','záda střed','záda levá') COLLATE cp1250_czech_cs DEFAULT NULL,
svoPoloha enum('vpravo','střed','vlevo','vlevo 4p') COLLATE cp1250_czech_cs DEFAULT NULL,
svoCis char(6) COLLATE cp1250_czech_cs DEFAULT NULL,
svoSmer varchar(60) COLLATE cp1250_czech_cs DEFAULT NULL,
svoPozn varchar(100) COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (ncis),
CONSTRAINT svo_ncis FOREIGN KEY (ncis) REFERENCES nosice (NCis)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table svoobdobi

DROP TABLE IF EXISTS svoobdobi;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE svoobdobi (
ncis int(11) NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
svoStav enum('balíček','pronájem','rezervace','cizí','volná') COLLATE cp1250_czech_cs DEFAULT NULL,
svoTyp enum('B flex','C flex') COLLATE cp1250_czech_cs DEFAULT NULL,
balicek smallint(6) DEFAULT NULL,
ncena smallint(6) DEFAULT NULL,
zsleva tinyint(4) DEFAULT NULL,
idKlient smallint(5) unsigned DEFAULT NULL,
idAgent smallint(5) unsigned DEFAULT NULL,
idZak smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (ncis,idObdobi),
KEY svoo_obdobi (idObdobi),
KEY svoo_klient_idx (idKlient),
KEY svoo_zak_idx (idZak),
KEY svoo?agent_idx (idAgent),
CONSTRAINT svoo_agent FOREIGN KEY (idAgent) REFERENCES firmy (idFirmy),
CONSTRAINT svoo_klient FOREIGN KEY (idKlient) REFERENCES firmy (idFirmy),
CONSTRAINT svoo_ncis FOREIGN KEY (ncis) REFERENCES nosice (NCis),
CONSTRAINT svoo_obdobi FOREIGN KEY (idObdobi) REFERENCES obdobi (idObdobi),
CONSTRAINT svoo_zak FOREIGN KEY (idZak) REFERENCES zakazky (idZak) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table tiskarny

DROP TABLE IF EXISTS tiskarny;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE tiskarny (
idTiskarny smallint(5) unsigned NOT NULL AUTO_INCREMENT,
Tiskarna varchar(80) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
tEmail varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (idTiskarny),
UNIQUE KEY tisk_email (tEmail)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table undozak

DROP TABLE IF EXISTS undozak;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE undozak (
idUndo int(11) unsigned NOT NULL AUTO_INCREMENT,
idZak smallint(5) unsigned NOT NULL,
uTime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
uPopis varchar(80) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
idOsoby smallint(5) unsigned DEFAULT NULL,
aktivni tinyint(4) DEFAULT '0',
PRIMARY KEY (idUndo),
KEY undo_zak_idx (idZak),
KEY undo_osoba_idx (idOsoby),
CONSTRAINT undo_osoba FOREIGN KEY (idOsoby) REFERENCES osoby (idOsoby),
CONSTRAINT undo_zak FOREIGN KEY (idZak) REFERENCES zakazky (idZak) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=97764 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table undozaknos

DROP TABLE IF EXISTS undozaknos;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE undozaknos (
idUndo int(11) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
ncis int(11) NOT NULL,
X tinyint(3) unsigned DEFAULT NULL,
XZ tinyint(3) unsigned DEFAULT NULL,
Aud tinyint(3) unsigned DEFAULT NULL,
Obsaz char(2) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Motiv smallint(5) unsigned DEFAULT NULL,
PCena mediumint(9) DEFAULT NULL,
TCena smallint(5) unsigned DEFAULT NULL,
Pocet smallint(6) NOT NULL DEFAULT '1',
PRIMARY KEY (idUndo,ncis,idObdobi),
KEY undonos_obdobi (idObdobi),
KEY undonos_ncis_idx (ncis),
CONSTRAINT undonos_ncis FOREIGN KEY (ncis) REFERENCES nosice (NCis),
CONSTRAINT undonos_obdobi FOREIGN KEY (idObdobi) REFERENCES obdobi (idObdobi),
CONSTRAINT undonos_zak FOREIGN KEY (idUndo) REFERENCES undozak (idUndo) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table undozakp

DROP TABLE IF EXISTS undozakp;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE undozakp (
idUndo int(11) unsigned NOT NULL,
ncis int(11) NOT NULL,
PTyp char(1) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
PCis smallint(6) DEFAULT NULL,
PMotiv smallint(5) unsigned DEFAULT NULL,
Info varchar(80) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
kVyznam tinyint(4) DEFAULT NULL,
kStrid tinyint(4) DEFAULT NULL,
mDesek tinyint(4) DEFAULT NULL,
Vzdalenost varchar(60) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Sipka varchar(60) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Strany tinyint(4) DEFAULT NULL,
NCena mediumint(9) DEFAULT NULL,
idAgent smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (idUndo,ncis),
KEY undozak_nos_idx (ncis),
KEY undozak_agent_idx (idAgent),
CONSTRAINT undozak_agent FOREIGN KEY (idAgent) REFERENCES firmy (idFirmy),
CONSTRAINT undozak_nos FOREIGN KEY (ncis) REFERENCES nosice (NCis),
CONSTRAINT undozak_undo FOREIGN KEY (idUndo) REFERENCES undozak (idUndo) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table velikosti

DROP TABLE IF EXISTS velikosti;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE velikosti (
Xvel varchar(20) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
Velikost varchar(20) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Typ char(1) CHARACTER SET cp1250 COLLATE cp1250_general_ci DEFAULT NULL,
PRIMARY KEY (Xvel)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table vfaktury

DROP TABLE IF EXISTS vfaktury;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE vfaktury (
idFakt int(11) unsigned NOT NULL AUTO_INCREMENT,
vfStav char(1) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
idDok smallint(6) unsigned NOT NULL,
idZak smallint(5) unsigned DEFAULT NULL,
vfDFakt date DEFAULT NULL,
vfDUZP date DEFAULT NULL,
vfSplatnost tinyint(4) DEFAULT NULL,
vfCCelkem float DEFAULT NULL,
vfDPH tinyint(4) DEFAULT NULL,
vfCCelkemS float GENERATED ALWAYS AS ((round(((vfCCelkem * (1 + (vfDPH / 100))) * 100),0) / 100)) STORED,
vfCisPoh varchar(12) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
vfText varchar(250) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
vfPozn varchar(250) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
PRIMARY KEY (idFakt),
KEY faktura_doc_idx (idDok),
KEY faktura_zak_idx (idZak),
CONSTRAINT faktura_dok FOREIGN KEY (idDok) REFERENCES dokumenty (idDok),
CONSTRAINT faktura_zak FOREIGN KEY (idZak) REFERENCES zakazky (idZak) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=25304 DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table vfakturyp

DROP TABLE IF EXISTS vfakturyp;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE vfakturyp (
idFakt int(11) unsigned NOT NULL,
idfPol tinyint(4) NOT NULL COMMENT 'pořadí',
vfpText varchar(120) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
vfpCena1 float DEFAULT NULL,
vfpPocet int(11) DEFAULT NULL,
vfpJedn varchar(6) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
vfpCena float GENERATED ALWAYS AS ((vfpCena1 * vfpPocet)) VIRTUAL,
vfpFrekv tinyint(4) DEFAULT NULL COMMENT '0 - jednorázový\n1 - měsíc\n-1 - konec měsíce\n',
PRIMARY KEY (idFakt,idfPol),
CONSTRAINT faktpol_fak FOREIGN KEY (idFakt) REFERENCES vfaktury (idFakt)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table vylepy

DROP TABLE IF EXISTS vylepy;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE vylepy (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
idSkup smallint(5) unsigned DEFAULT NULL,
Reference varchar(100) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
Material varchar(100) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
dExpedice date DEFAULT NULL,
dDodani date DEFAULT NULL,
dVylep date DEFAULT NULL,
idTiskarny smallint(5) unsigned DEFAULT NULL,
UNIQUE KEY idZakObdSkup_UNIQUE (idZak,idObdobi,idSkup),
KEY vylep_tiskarna_idx (idTiskarny),
CONSTRAINT vylep_tiskarna FOREIGN KEY (idTiskarny) REFERENCES tiskarny (idTiskarny),
CONSTRAINT vylep_zakobdobi FOREIGN KEY (idZak, idObdobi) REFERENCES zakobdobi (idZak, idObdobi) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

SET character_set_client = @saved_cs_client;

--
-- Table structure for table zakazky

DROP TABLE IF EXISTS zakazky;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakazky (
idZak smallint(5) unsigned NOT NULL AUTO_INCREMENT,
ZTyp char(3) DEFAULT NULL,
idKlient smallint(5) unsigned NOT NULL,
ZNazev varchar(45) NOT NULL,
idKraj tinyint(3) unsigned DEFAULT NULL,
Mesto varchar(45) DEFAULT NULL,
idOsoby smallint(5) unsigned NOT NULL,
DPrac datetime DEFAULT NULL,
Stav char(1) NOT NULL COMMENT 'S-Smlouva\\nD-Dokončeno\\nR-Rozpracovaná\\nP-Pomocná\\nG-Generovaná\\nV-Vyřazená\nT-Testovací',
zEdit tinyint(4) NOT NULL DEFAULT '0',
idDokFakt smallint(6) unsigned DEFAULT NULL,
Firma tinyint(4) NOT NULL DEFAULT '1',
idzDir smallint(5) unsigned DEFAULT NULL,
zMena enum('Kč','€','c€') NOT NULL DEFAULT 'Kč',
idNadObdobi smallint(5) unsigned DEFAULT NULL,
zKorp enum('normal','prodejny','korporace') NOT NULL DEFAULT 'normal',
idZakRodic smallint(5) unsigned DEFAULT NULL,
zVazba enum('kopie','pokračování','agentura','korp agent') DEFAULT NULL,
zOpce tinyint(4) DEFAULT NULL,
PRIMARY KEY (idZak),
KEY Firma (Firma),
KEY Korporatni Navigace (ZTyp,idKlient),
KEY zakazka_klient_idx (idKlient),
KEY zakazka_osoba_idx (idOsoby),
KEY zakazka_dir_idx (idzDir),
KEY zakazka_rodic_idx (idZakRodic),
KEY zakazka_nadobdobi_idx (idNadObdobi),
CONSTRAINT zakazka_dir FOREIGN KEY (idzDir) REFERENCES dir (idDir),
CONSTRAINT zakazka_klient FOREIGN KEY (idKlient) REFERENCES firmy (idFirmy),
CONSTRAINT zakazka_nadobdobi FOREIGN KEY (idNadObdobi) REFERENCES nadobdobi (idObdobi),
CONSTRAINT zakazka_osoba FOREIGN KEY (idOsoby) REFERENCES osoby (idOsoby),
CONSTRAINT zakazka_rodic FOREIGN KEY (idZakRodic) REFERENCES zakazky (idZak)
) ENGINE=InnoDB AUTO_INCREMENT=8765 DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakazkyp

DROP TABLE IF EXISTS zakazkyp;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakazkyp (
idZak smallint(5) unsigned NOT NULL,
NCis int(11) NOT NULL,
PTyp char(1) NOT NULL,
PCis smallint(6) NOT NULL,
PMotiv smallint(5) unsigned DEFAULT '1',
Info varchar(80) DEFAULT NULL,
kVyznam tinyint(4) DEFAULT NULL,
kStrid tinyint(4) DEFAULT NULL,
mDesek tinyint(4) DEFAULT NULL,
Vzdalenost varchar(60) DEFAULT NULL,
Sipka varchar(60) DEFAULT NULL,
Strany tinyint(4) DEFAULT '1',
NCena mediumint(9) DEFAULT NULL,
idAgent smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (idZak,NCis),
UNIQUE KEY pcis (idZak,PTyp,PCis),
KEY zakp_ncis_idx (NCis),
KEY zakp_agent_idx (idAgent),
CONSTRAINT zakp_agent FOREIGN KEY (idAgent) REFERENCES firmy (idFirmy),
CONSTRAINT zakp_ncis FOREIGN KEY (NCis) REFERENCES nosice (NCis),
CONSTRAINT zakp_zak FOREIGN KEY (idZak) REFERENCES zakazky (idZak) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakdok

DROP TABLE IF EXISTS zakdok;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakdok (
idDok smallint(5) unsigned NOT NULL,
idZak smallint(6) unsigned NOT NULL,
zdTyp char(1) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT 'D',
zdCena float DEFAULT NULL,
PRIMARY KEY (idDok,idZak),
KEY doc_zak_idx (idZak),
CONSTRAINT zak_doc FOREIGN KEY (idDok) REFERENCES dokumenty (idDok),
CONSTRAINT zakdoc_zak FOREIGN KEY (idZak) REFERENCES zakazky (idZak)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakloga

DROP TABLE IF EXISTS zakloga;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakloga (
idZak smallint(5) unsigned NOT NULL,
idLogo smallint(5) unsigned NOT NULL,
PRIMARY KEY (idZak,idLogo),
KEY zak_logo_idx (idLogo),
CONSTRAINT logo_zak FOREIGN KEY (idZak) REFERENCES zakazky (idZak),
CONSTRAINT zak_logo FOREIGN KEY (idLogo) REFERENCES loga (idLogo) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zaknos

DROP TABLE IF EXISTS zaknos;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zaknos (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
ncis int(11) NOT NULL,
X tinyint(1) unsigned NOT NULL DEFAULT '0',
XZ tinyint(1) unsigned NOT NULL DEFAULT '0',
Aud tinyint(1) unsigned NOT NULL DEFAULT '0',
Obsaz char(2) NOT NULL DEFAULT '',
Motiv smallint(5) unsigned DEFAULT '1',
PCena mediumint(9) DEFAULT NULL,
TCena smallint(5) unsigned DEFAULT NULL,
Pocet smallint(6) NOT NULL DEFAULT '1',
PRIMARY KEY (idZak,idObdobi,ncis),
KEY IDZak & IDObdobi (idZak,idObdobi) /
!80000 INVISIBLE /,
KEY IDZak & ncis (idZak,ncis),
KEY zaknos_skup_idx (idObdobi,ncis),
KEY zaknos_motiv (Motiv),
CONSTRAINT zaknos_motiv FOREIGN KEY (Motiv) REFERENCES motivy (Motiv) ON DELETE SET NULL,
CONSTRAINT zaknos_skup FOREIGN KEY (idObdobi, ncis) REFERENCES nosskup (idObdobi, ncis),
CONSTRAINT zaknos_zakobdobi FOREIGN KEY (idZak, idObdobi) REFERENCES zakobdobi (idZak, idObdobi) ON DELETE CASCADE,
CONSTRAINT zaknos_zakp FOREIGN KEY (idZak, ncis) REFERENCES zakazkyp (idZak, NCis) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zaknosprod

DROP TABLE IF EXISTS zaknosprod;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zaknosprod (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
ncis int(11) NOT NULL,
idProdukce smallint(6) NOT NULL,
val int(11) DEFAULT NULL,
ks int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (idZak,idObdobi,ncis,idProdukce),
KEY zaknosprod_prod_idx (idProdukce),
CONSTRAINT zaknosprod_prod FOREIGN KEY (idProdukce) REFERENCES produkce (idProdukce),
CONSTRAINT zaknosprod_zaknos FOREIGN KEY (idZak, idObdobi, ncis) REFERENCES zaknos (idZak, idObdobi, ncis) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakobdobi

DROP TABLE IF EXISTS zakobdobi;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakobdobi (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
Poradi tinyint(4) DEFAULT NULL COMMENT '--delete',
DCena smallint(6) DEFAULT NULL,
PRIMARY KEY (idZak,idObdobi),
KEY zak_obdobi (idObdobi),
CONSTRAINT obdobi_zakazky FOREIGN KEY (idZak) REFERENCES zakazky (idZak) ON DELETE CASCADE,
CONSTRAINT zak_obdobi FOREIGN KEY (idObdobi) REFERENCES obdobi (idObdobi)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakostatni

DROP TABLE IF EXISTS zakostatni;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakostatni (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL COMMENT '0 - pro kazde obdobi\n',
zoText varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
zoCena int(11) DEFAULT NULL,
zoPocet int(11) DEFAULT NULL COMMENT '-1 = krat x\n',
zoJednotka varchar(6) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
zoDFakt date DEFAULT NULL,
PRIMARY KEY (idZak,idObdobi),
CONSTRAINT zakost_zakobdobi FOREIGN KEY (idZak, idObdobi) REFERENCES zakobdobi (idZak, idObdobi) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakpkorp

DROP TABLE IF EXISTS zakpkorp;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakpkorp (
idZak smallint(5) unsigned NOT NULL,
ncis int(11) NOT NULL,
idAgent smallint(5) unsigned DEFAULT NULL,
SAPobj bigint(20) DEFAULT NULL,
VlastTab char(2) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
cTisk mediumint(8) unsigned DEFAULT NULL,
cTabPrel mediumint(8) unsigned DEFAULT NULL,
cVylep mediumint(8) unsigned DEFAULT NULL,
PRIMARY KEY (idZak,ncis),
KEY zakkorp_agent_idx (idAgent),
CONSTRAINT zakkorp_agent FOREIGN KEY (idAgent) REFERENCES firmy (idFirmy),
CONSTRAINT zakkorp_zakp FOREIGN KEY (idZak, ncis) REFERENCES zakazkyp (idZak, NCis) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakprefakt

DROP TABLE IF EXISTS zakprefakt;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakprefakt (
idZak smallint(5) unsigned NOT NULL,
Specifikace varchar(250) CHARACTER SET cp1250 COLLATE cp1250_czech_cs DEFAULT NULL,
SpecDet text CHARACTER SET cp1250 COLLATE cp1250_czech_cs,
zpSplatnost tinyint(4) DEFAULT NULL,
zpFrekvence tinyint(4) DEFAULT NULL,
zpFixNakl tinyint(4) DEFAULT NULL,
zpJednatel smallint(6) DEFAULT NULL,
zpKlJednatel smallint(6) DEFAULT NULL,
PRIMARY KEY (idZak),
CONSTRAINT perfakt_zak FOREIGN KEY (idZak) REFERENCES zakazky (idZak) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakprod

DROP TABLE IF EXISTS zakprod;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakprod (
idZak smallint(5) unsigned NOT NULL,
idProd smallint(5) unsigned NOT NULL,
PRIMARY KEY (idZak,idProd),
KEY prod_zak_idx (idProd),
CONSTRAINT prod_zak FOREIGN KEY (idProd) REFERENCES prodejny (idProd),
CONSTRAINT zak_prod FOREIGN KEY (idZak) REFERENCES zakazky (idZak) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs COMMENT='zakazka <-> prodejna';
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zakrez

DROP TABLE IF EXISTS zakrez;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zakrez (
idZak smallint(5) unsigned NOT NULL,
idObdobi smallint(5) unsigned NOT NULL,
ncis int(11) NOT NULL,
rPoradi smallint(6) unsigned NOT NULL,
rOpce tinyint(4) unsigned DEFAULT NULL,
PRIMARY KEY (idZak,idObdobi,ncis),
CONSTRAINT zakrez_zaknos FOREIGN KEY (idZak, idObdobi, ncis) REFERENCES zaknos (idZak, idObdobi, ncis) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table zaksoubory

DROP TABLE IF EXISTS zaksoubory;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!50503 SET character_set_client = utf8mb4 /;
CREATE TABLE zaksoubory (
fname varchar(200) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
fext varchar(20) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL,
idOsoby smallint(5) unsigned NOT NULL,
fdate datetime DEFAULT NULL,
fSize int(11) DEFAULT NULL,
PRIMARY KEY (fname,fext,idOsoby),
KEY zaksoubor_osoba_idx (idOsoby),
CONSTRAINT zaksoubor_osoba FOREIGN KEY (idOsoby) REFERENCES osoby (idOsoby)
) ENGINE=InnoDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs;
/
!40101 SET character_set_client = @saved_cs_client */;

schema.prisma
generator client {
  provider = "prisma-client-js"
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}

model Cart {
assignedTo Int?
cartID Int @default(autoincrement()) @id
email String
endPeriodID Int
startPeriodID Int
osoby osoby? @relation(fields: [assignedTo], references: [idOsoby])
PeriodEnd obdobi @relation("Cart_endPeriodToobdobi", fields: [endPeriodID], references: [idObdobi])
PeriodStart obdobi @relation("Cart_startPeriodToobdobi", fields: [startPeriodID], references: [idObdobi])
CartItem CartItem[]

@@index([assignedTo], name: "cartAssignement_idx")
@@index([endPeriodID], name: "cartPeriodEnd_idx")
@@index([startPeriodID], name: "cartPeriodStart_idx")
}

model CartItem {
cartID Int
NCis Int
Carrier nosice @relation(fields: [NCis], references: [NCis])
Cart Cart @relation(fields: [cartID], references: [cartID])

@@id([cartID, NCis])
@@index([NCis], name: "cartCarrier_idx")
}

model adresy {
aMesto String?
aOdd String?
aPozn String?
aPSC String?
aStat String?
aUlice String?
idAdr Int @default(autoincrement()) @id
idFirmy Int
firmy_adresy_idFirmyTofirmy firmy @relation("adresy_idFirmyTofirmy", fields: [idFirmy], references: [idFirmy])
dokumenty dokumenty[]
firmy_adresyTofirmy_idFirAdr firmy[] @relation("adresyTofirmy_idFirAdr")
firmy_adresyTofirmy_idKorespAdr firmy[] @relation("adresyTofirmy_idKorespAdr")
firmy_adresyTofirmy_idLepicAdr firmy[] @relation("adresyTofirmy_idLepicAdr")

@@index([idFirmy], name: "key_idx")
}

model alarm {
aStav Int?
aTyp Int?
dAlarm DateTime?
dUdalost DateTime?
idAlarm Int @default(autoincrement()) @id
idOsoby Int?
idZak Int?
ks Int?
MyFirma Int?
Udalost String?
osoby osoby? @relation(fields: [idOsoby], references: [idOsoby])
zakazky zakazky? @relation(fields: [idZak], references: [idZak])

@@index([idOsoby], name: "alarm_osoba_idx")
@@index([dAlarm], name: "dAlarm")
@@index([idZak], name: "zakazka_idx")
}

model audit {
aDatum DateTime
aOsoba Int
audit String
idObdobi Int
ncis Int
osoby osoby @relation(fields: [aOsoba], references: [idOsoby])
obdobi obdobi @relation(fields: [idObdobi], references: [idObdobi])
nosice nosice @relation(fields: [ncis], references: [NCis])

@@id([ncis, idObdobi])
@@index([idObdobi], name: "obdobi")
@@index([aOsoba], name: "osoba_idx")
}

model auditnos {
aDatum DateTime
aStav auditnos_aStav
Audit String
idAudit Int @default(autoincrement()) @id
idKlient Int
ncis Int
firmy firmy @relation(fields: [idKlient], references: [idFirmy])
nosice nosice @relation(fields: [ncis], references: [NCis])
fotoaudit fotoaudit[]

@@index([aDatum], name: "aDatum")
@@index([ncis, aDatum, idKlient], name: "auditnos")
@@index([idKlient], name: "auditnos_klient_idx")
@@index([ncis], name: "ncis")
}

model auditprod {
aDatum DateTime?
Audit String?
idObdobi Int
idProd Int

@@id([idProd, idObdobi])
}

model dir {
dir String
dirPopis String?
dirPrim Int?
idDir Int @default(autoincrement()) @id
dokumenty dokumenty[]
firmy firmy[]
zakazky zakazky[]

@@index([dir], name: "dir")
}

model dokumenty {
dokCCena Float?
dokCislo String?
dokDo DateTime?
dokDPodpis DateTime?
dokDruh String?
dokExt String?
dokFakt String?
dokFirma Int @default(1)
dokKCislo String?
dokMena mena @default(kc)
dokNazev String?
dokNeurcita dokumenty_dokNeurcita?
dokOd DateTime?
dokPDF Int @default(0)
dokPrac Int?
dokSeznam Int?
dokTyp Int?
dokVypMes Int?
idAdrKP Int?
idDir Int @default(2)
idDok Int @default(autoincrement()) @id
idDokNad Int?
idFirmy Int
idKlient Int?
idOsoby Int?
idZak Int?
firmy_dokumenty_dokFirmaTofirmy firmy @relation("dokumenty_dokFirmaTofirmy", fields: [dokFirma], references: [idFirmy])
adresy adresy? @relation(fields: [idAdrKP], references: [idAdr])
dir dir @relation(fields: [idDir], references: [idDir])
firmy_dokumenty_idFirmyTofirmy firmy @relation("dokumenty_idFirmyTofirmy", fields: [idFirmy], references: [idFirmy])
firmy_dokumenty_idKlientTofirmy firmy? @relation("dokumenty_idKlientTofirmy", fields: [idKlient], references: [idFirmy])
osoby osoby? @relation(fields: [idOsoby], references: [idOsoby])
zakazky zakazky? @relation(fields: [idZak], references: [idZak])
nosdok nosdok[]
vfaktury vfaktury[]
zakdok zakdok[]

@@index([idAdrKP], name: "doc_adr_idx")
@@index([idDir], name: "doc_dir_idx")
@@index([idFirmy], name: "doc_firma_idx")
@@index([idKlient], name: "doc_klient_idx")
@@index([idOsoby], name: "doc_osoba_idx")
@@index([dokFirma], name: "doc_zadavatel_idx")
@@index([idZak], name: "doc_zak_idx")
}

model firmy {
Cinnost String?
DIC String?
fAktivni Int @default(1)
fDodav Int @default(0)
fFax String?
FFirma String
fKat firmy_fKat?
fKlient Int @default(0)
FNazev String?
fPozn String?
Frekvence Int? @default(dbgenerated())
fRSdod Int @default(0)
fSoud String?
fTel String?
ICO String?
idFirAdr Int?
idFirmy Int @id
idkDir Int?
idKorespAdr Int?
idLepic Int?
idLepicAdr Int?
idPrimKontakt Int?
idZastoupena Int?
Region String?
Splatnost Int? @default(14)
adresy_adresyTofirmy_idFirAdr adresy? @relation("adresyTofirmy_idFirAdr", fields: [idFirAdr], references: [idAdr])
adresy_adresyTofirmy_idKorespAdr adresy? @relation("adresyTofirmy_idKorespAdr", fields: [idKorespAdr], references: [idAdr])
adresy_adresyTofirmy_idLepicAdr adresy? @relation("adresyTofirmy_idLepicAdr", fields: [idLepicAdr], references: [idAdr])
dir dir? @relation(fields: [idkDir], references: [idDir])
adresy_adresy_idFirmyTofirmy adresy[] @relation("adresy_idFirmyTofirmy")
auditnos auditnos[]
dokumenty_dokumenty_dokFirmaTofirmy dokumenty[] @relation("dokumenty_dokFirmaTofirmy")
dokumenty_dokumenty_idFirmyTofirmy dokumenty[] @relation("dokumenty_idFirmyTofirmy")
dokumenty_dokumenty_idKlientTofirmy dokumenty[] @relation("dokumenty_idKlientTofirmy")
jmena jmena[]
korporace korporace[]
korposoby korposoby[]
loga loga[]
nadobdobi nadobdobi[]
nosice nosice[]
prodejny prodejny[]
rsnosice rsnosice[]
svoobdobi_firmyTosvoobdobi_idAgent svoobdobi[] @relation("firmyTosvoobdobi_idAgent")
svoobdobi_firmyTosvoobdobi_idKlient svoobdobi[] @relation("firmyTosvoobdobi_idKlient")
undozakp undozakp[]
zakazky zakazky[]
zakazkyp zakazkyp[]
zakpkorp zakpkorp[]

@@index([idKorespAdr], name: "firma_adr_idx")
@@index([idFirAdr], name: "firma_adr_idx1")
@@index([idkDir], name: "firma_dir_idx")
@@index([idLepicAdr], name: "firma_lepard_idx")
}

model fotoaudit {
fName String
idAudit Int
Verze Int
auditnos auditnos @relation(fields: [idAudit], references: [idAudit])

@@id([idAudit, Verze])
}

model fotodoc {
fName String
idObdobi Int
idSkup Int?
idZak Int
nCis Int
verze Int
skupiny skupiny? @relation(fields: [idSkup], references: [idSkup])
zaknos zaknos @relation(fields: [idZak, idObdobi, nCis], references: [idZak, idObdobi, ncis])

@@index([idSkup], name: "fotodoc_skupina")
@@index([idZak, nCis, idObdobi], name: "ncis & obdobi & idZak")
@@unique([idZak, idObdobi, nCis, idSkup, verze], name: "idZak_UNIQUE")
}

model fotogr {
fname String?
idZak Int
ncis Int
zakazkyp zakazkyp @relation(fields: [ncis, idZak], references: [NCis, idZak])

@@id([ncis, idZak])
}

model fotomapy {
fName String
nCis Int
verze Int @default(autoincrement())
nosice nosice @relation(fields: [nCis], references: [NCis])

@@id([verze, nCis])
@@index([nCis], name: "fotomapy_nosic_idx")
}

model fotoprod {
fName String
idObdobi Int
idProd Int
obdobi obdobi @relation(fields: [idObdobi], references: [idObdobi])
prodejny prodejny @relation(fields: [idProd], references: [idProd])

@@id([idProd, idObdobi])
@@index([idObdobi], name: "fotoprod_obdobi")
}

model fotorl {
fName String
nCis Int
verze Int @default(autoincrement())
nosice nosice @relation(fields: [nCis], references: [NCis])

@@id([verze, nCis])
@@index([nCis], name: "nCis")
}

model jmena {
email String?
idFirmy Int
idJmena Int @default(autoincrement()) @id
jednatel Int?
Jmeno String? @default("")
jPozn String?
kontakt Int?
Prijmeni String
tel String?
Titul String? @default("")
firmy firmy @relation(fields: [idFirmy], references: [idFirmy])

@@index([idFirmy], name: "jmeno_firma_idx")
}

model kategorie {
hex String
idKat Int @id
Kategorie String @unique
kBarva Int?
kZakl Int?
}

model korporace {
delkaObdobi Int?
delkaObdobiAudit Int?
idKlient Int @id
idLogo Int?
idObdobi1 Int?
idObdobiAudit1 Int?
korpFirma Int?
KorpNazev String?
otyp String?
otypaudit String?
loga loga? @relation(fields: [idLogo], references: [idLogo])
obdobi_korporace_idObdobi1Toobdobi obdobi? @relation("korporace_idObdobi1Toobdobi", fields: [idObdobi1], references: [idObdobi])
obdobi_korporace_idObdobiAudit1Toobdobi obdobi? @relation("korporace_idObdobiAudit1Toobdobi", fields: [idObdobiAudit1], references: [idObdobi])
firmy firmy? @relation(fields: [korpFirma], references: [idFirmy])

@@index([idObdobiAudit1], name: "auditkorp_obdobi_idx")
@@index([korpFirma], name: "korp_firma_idx")
@@index([idLogo], name: "korp_logo_idx")
@@index([idObdobi1], name: "korp_obdobi")
}

model korposoby {
Funkce korposoby_Funkce?
hashInc Int @default(0)
Heslo String?
idKlient Int?
idKorpOsoby Int @default(autoincrement()) @id
idNad Int?
idProd Int?
Jmeno String?
level Int
Prijmeni String @unique
firmy firmy? @relation(fields: [idKlient], references: [idFirmy])
korposoby korposoby? @relation("korposobyTokorposoby_idNad", fields: [idNad], references: [idKorpOsoby])
prodejny prodejny? @relation(fields: [idProd], references: [idProd])
other_korposoby korposoby[] @relation("korposobyTokorposoby_idNad")

@@index([idNad], name: "idNad")
@@index([idProd], name: "idProd")
@@index([idKlient], name: "korpOsoby_klient_idx")
}

model kraj {
idKraj Int @id
Kraj String
nosice nosice[]
prodejny prodejny[]
rsnosice rsnosice[]
}

// The underlying table does not contain a unique identifier and can therefore currently not be handled.
// model kraje {
// idKr Int?
// Kraj String
// XKraj String
// kraj kraj? @relation(fields: [idKr], references: [idKraj])

// @@index([idKr], name: "index1")
// }

model loga {
idKlient Int?
idLogo Int @default(autoincrement()) @id
Logo String?
skupina loga_skupina?
Soubor String?
firmy firmy? @relation(fields: [idKlient], references: [idFirmy])
korporace korporace[]
miniprod miniprod[]
zakloga zakloga[]

@@index([Logo], name: "Logo")
@@index([idKlient], name: "logo_klient_idx")
}

model mapperitem {
color Int
hex String
idMapper Int
idObdobi Int
idZak Int
mappername mappername @relation(fields: [idMapper], references: [idMapper])
zakobdobi zakobdobi @relation(fields: [idZak, idObdobi], references: [idZak, idObdobi])

@@id([idMapper, idZak])
@@index([idZak, idObdobi], name: "mapper_zakobdobi_idx")
}

model mappername {
idMapper Int @default(autoincrement()) @id
idOsoby Int?
Name String
osoby osoby? @relation(fields: [idOsoby], references: [idOsoby])
mapperitem mapperitem[]

@@index([idOsoby], name: "mapper_osoba_idx")
}

model miniprod {
idLogo Int
idMiniprod Int @default(autoincrement()) @id
lat Float @default(0)
lng Float @default(0)
loga loga @relation(fields: [idLogo], references: [idLogo])

@@index([idLogo], name: "Logo_idx")
}

model motivy {
hex String
idKat Int @default(1)
mBarva Int
midZak Int? @default(0)
Motiv Int @default(autoincrement()) @id
mSkup motivy_mSkup?
mText String
mTyp String?
mZakl Int?
mZkratka String?
zakazky zakazky? @relation(fields: [midZak], references: [idZak])
nosskup nosskup[]
zaknos zaknos[]

@@index([midZak], name: "motiv_idZak_idx")
}

model myfirmy {
idDod Int?
idMyFirmy Int @id
mfICO String?
mfJednatel Int?
mfKursEur Float?
mfMesto String?
mfNazev String?
mfPohmServer String?
mfPohRada String?
mfPsc String?
mfUlice String?
}

model nabidka {
Cis Int
idOsoby Int
X Int?

@@id([Cis, idOsoby])
}

model nabzak {
idObdobi Int
idZak Int
ncis Int
obsaz String?
X Int?
zaknos zaknos @relation(fields: [idZak, idObdobi, ncis], references: [idZak, idObdobi, ncis])

@@id([idZak, ncis, idObdobi])
@@index([idZak, idObdobi, ncis], name: "nabzak_zaknos")
}

model nadobdobi {
idKlient Int
idObdobi Int
noTyp nadobdobi_noTyp @default(m)
firmy firmy @relation(fields: [idKlient], references: [idFirmy])
obdobi obdobi @relation(fields: [idObdobi], references: [idObdobi])
zakazky zakazky[]

@@id([idKlient, idObdobi])
@@index([idObdobi], name: "nadbodobi_obdobi")
}

model nosdok {
idDok Int
ncis Int
dokumenty dokumenty @relation(fields: [idDok], references: [idDok])
nosice nosice @relation(fields: [ncis], references: [NCis])

@@id([idDok, ncis])
@@index([ncis], name: "nosdok_nos_idx")
}

model nosice {
Azimut Int? @default(dbgenerated())
GpsNase Int? @default(0)
idDod Int?
idKraj Int @default(0)
kExkl Int?
kOkolo Int?
kOsv Int?
kPol Int?
kVel Int?
kVid Int?
lat Float?
lng Float?
Mesto String?
NCis Int @id
NPozn String?
Osvetleni Int?
Plocha Float?
Poloha Int?
Popis String?
Prujezd Int?
TextNase Int? @default(0)
Typ String?
Ulice String?
VCis String?
Velikost String?
Videt Int?
Zdroj String?
firmy firmy? @relation(fields: [idDod], references: [idFirmy])
kraj kraj @relation(fields: [idKraj], references: [idKraj])
CartItem CartItem[]
audit audit[]
auditnos auditnos[]
fotomapy fotomapy[]
fotorl fotorl[]
nosdok nosdok[]
nosiceex nosiceex[]
nosprod nosprod[]
nosvyb nosvyb[]
rezervacep rezervacep[]
rsnosice rsnosice[]
svo svo[]
svoobdobi svoobdobi[]
undozaknos undozaknos[]
undozakp undozakp[]
zakazkyp zakazkyp[]

@@index([idDod], name: "nosic_dodavatel_idx")
@@index([idKraj], name: "nosic_kraj_idx")
}

model nosiceex {
exAlkohol Int?
exKasino Int?
exNabytek Int?
exNCena Int?
exPolitika Int?
exPotraviny Int?
exRezervace Int? @default(0)
exSex Int?
ncis Int @id
nosice nosice @relation(fields: [ncis], references: [NCis])
}

model nosprod {
idObdobi Int
idProd Int
ncis Int
podil Int? @default(1)
obdobi obdobi @relation(fields: [idObdobi], references: [idObdobi])
prodejny prodejny @relation(fields: [idProd], references: [idProd])
nosice nosice @relation(fields: [ncis], references: [NCis])

@@id([ncis, idProd, idObdobi])
@@index([ncis, idObdobi], name: "nosobd")
@@index([idObdobi], name: "nosprod_obdobi")
@@index([idProd], name: "nosprod_prod_idx")
}

model nosskup {
idMotiv Int
idObdobi Int
idSkup Int
idZak Int
ncis Int
nsPozn String?
produkce Int?
motivy motivy @relation(fields: [idMotiv], references: [Motiv])
skupiny skupiny @relation(fields: [idSkup], references: [idSkup])
zaknos_nosskup_idZak_idObdobi_ncisTozaknos zaknos @relation("nosskup_idZak_idObdobi_ncisTozaknos", fields: [idZak, idObdobi, ncis], references: [idZak, idObdobi, ncis])
zaknos_nosskupTozaknos_idObdobi_ncis zaknos[] @relation("nosskupTozaknos_idObdobi_ncis")

@@id([idObdobi, ncis, idSkup, idZak])
@@index([idSkup], name: "idSkup")
@@index([idMotiv], name: "nosskup_motiv")
@@index([idZak, idObdobi, ncis], name: "nosskup_zaknos")
@@index([idZak, idObdobi, idSkup], name: "zaknos")
}

model nosvyb {
celkem Int @default(0)
cetnost Float?
NCis Int
nevybrano Int?
typKamp String
vybrano Int @default(0)
nosice nosice @relation(fields: [NCis], references: [NCis])

@@id([NCis, typKamp])
}

model obdobi {
delka Int
do DateTime
idObdobi Int @default(autoincrement()) @id
Obdobi String
od DateTime
otyp String @default("o")
RM Int?
Cart_Cart_endPeriodToobdobi Cart[] @relation("Cart_endPeriodToobdobi")
Cart_Cart_startPeriodToobdobi Cart[] @relation("Cart_startPeriodToobdobi")
audit audit[]
fotoprod fotoprod[]
korporace_korporace_idObdobi1Toobdobi korporace[] @relation("korporace_idObdobi1Toobdobi")
korporace_korporace_idObdobiAudit1Toobdobi korporace[] @relation("korporace_idObdobiAudit1Toobdobi")
nadobdobi nadobdobi[]
nosprod nosprod[]
svoobdobi svoobdobi[]
undozaknos undozaknos[]
zakobdobi zakobdobi[]

@@unique([od, do, otyp], name: "Datumy")
}

model osoby {
Alias String @unique
Email String?
Heslo String?
idOsoby Int @default(autoincrement()) @id
Jednatel Int?
Jmeno String?
// This type is currently not supported.
// Podpis binary?
Prava Int? @default(3)
Tel String?
Cart Cart[]
alarm alarm[]
audit audit[]
dokumenty dokumenty[]
mappername mappername[]
undozak undozak[]
zakazky zakazky[]
zaksoubory zaksoubory[]
}

model print {
idOsoby Int?
idPrint Int @default(autoincrement()) @id
ncis Int?
}

model prodejny {
idKlient Int
idKraj Int?
idMiniprod Int?
idProd Int @id
Mesto String?
PKod Int
PPozn String?
Prodejna String
PSC String?
PTyp String?
Ulice String?
firmy firmy @relation(fields: [idKlient], references: [idFirmy])
kraj kraj? @relation(fields: [idKraj], references: [idKraj])
fotoprod fotoprod[]
korposoby korposoby[]
nosprod nosprod[]
zakprod zakprod[]

@@index([idKlient], name: "prod_klient_idx")
@@index([idKraj], name: "prod_kraj_idx")
}

model produkce {
idProdukce Int @id
prNazev String?
prZkratka String?
zaknosprod zaknosprod[]
}

model prujezd {
idprujezd Int @default(autoincrement()) @id
lat Float
lng Float
prujezd Int
}

model rezervace {
DKonec DateTime?
DPrac DateTime?
Email2 String? @default("")
idKlient Int?
idOsoby Int?
idRez Int @default(autoincrement()) @id
idZak Int? @default(0)
RDelka Int?
RMesic Int?
RPopis String?
RRok Int?
RStav String?
RZkratka String?
rezervacep rezervacep[]
}

model rezervacep {
idRez Int
Mesic Int
NCis Int
RM Int?
Rok Int
RPoradi Int @default(1)
nosice nosice @relation(fields: [NCis], references: [NCis])
rezervace rezervace @relation(fields: [idRez], references: [idRez])

@@id([idRez, NCis, Rok, Mesic])
@@index([NCis], name: "rez_ncis_idx")
}

model rsnosice {
Ctvrt String?
idDod Int
idKraj Int?
Kraj String?
lat Float?
lng Float?
Mesto String?
ncis Int @id
Osvetleni Int?
Poloha Int?
Popis String?
stav Int
tvelikost String?
typ String?
Ulice String?
Velikost String?
Videt Int?
firmy firmy @relation(fields: [idDod], references: [idFirmy])
kraj kraj? @relation(fields: [idKraj], references: [idKraj])
nosice nosice @relation(fields: [ncis], references: [NCis])

@@index([idDod], name: "rsnos_dod_idx")
@@index([idKraj], name: "rsnos_kraj_idx")
}

model skupiny {
hex String
idKat Int
idSkup Int @default(autoincrement())
idZak Int
sBarva Int
Skupina String
fotodoc fotodoc[]
nosskup nosskup[]

@@id([idSkup, idZak])
}

model svo {
ncis Int @id
svoCis String?
svoPoloha svo_svoPoloha?
svoPozice svo_svoPozice?
svoPozn String?
svoSmer String?
nosice nosice @relation(fields: [ncis], references: [NCis])
}

model svoobdobi {
balicek Int?
idAgent Int?
idKlient Int?
idObdobi Int
idZak Int?
ncena Int?
ncis Int
svoStav svoobdobi_svoStav?
svoTyp svoobdobi_svoTyp?
zsleva Int?
firmy_firmyTosvoobdobi_idAgent firmy? @relation("firmyTosvoobdobi_idAgent", fields: [idAgent], references: [idFirmy])
firmy_firmyTosvoobdobi_idKlient firmy? @relation("firmyTosvoobdobi_idKlient", fields: [idKlient], references: [idFirmy])
obdobi obdobi @relation(fields: [idObdobi], references: [idObdobi])
zakazky zakazky? @relation(fields: [idZak], references: [idZak])
nosice nosice @relation(fields: [ncis], references: [NCis])

@@id([ncis, idObdobi])
@@index([idAgent], name: "svoo?agent_idx")
@@index([idKlient], name: "svoo_klient_idx")
@@index([idObdobi], name: "svoo_obdobi")
@@index([idZak], name: "svoo_zak_idx")
}

model tiskarny {
idTiskarny Int @default(autoincrement()) @id
tEmail String? @unique
Tiskarna String?
vylepy vylepy[]
}

model undozak {
aktivni Int? @default(0)
idOsoby Int?
idUndo Int @default(autoincrement()) @id
idZak Int
uPopis String?
uTime DateTime @default(now())
osoby osoby? @relation(fields: [idOsoby], references: [idOsoby])
zakazky zakazky @relation(fields: [idZak], references: [idZak])
undozaknos undozaknos[]
undozakp undozakp[]

@@index([idOsoby], name: "undo_osoba_idx")
@@index([idZak], name: "undo_zak_idx")
}

model undozaknos {
Aud Int?
idObdobi Int
idUndo Int
Motiv Int?
ncis Int
Obsaz String?
PCena Int?
Pocet Int @default(1)
TCena Int?
X Int?
XZ Int?
obdobi obdobi @relation(fields: [idObdobi], references: [idObdobi])
undozak undozak @relation(fields: [idUndo], references: [idUndo])
nosice nosice @relation(fields: [ncis], references: [NCis])

@@id([idUndo, ncis, idObdobi])
@@index([ncis], name: "undonos_ncis_idx")
@@index([idObdobi], name: "undonos_obdobi")
}

model undozakp {
idAgent Int?
idUndo Int
Info String?
kStrid Int?
kVyznam Int?
mDesek Int?
NCena Int?
ncis Int
PCis Int?
PMotiv Int?
PTyp String?
Sipka String?
Strany Int?
Vzdalenost String?
firmy firmy? @relation(fields: [idAgent], references: [idFirmy])
undozak undozak @relation(fields: [idUndo], references: [idUndo])
nosice nosice @relation(fields: [ncis], references: [NCis])

@@id([idUndo, ncis])
@@index([idAgent], name: "undozak_agent_idx")
@@index([ncis], name: "undozak_nos_idx")
}

model velikosti {
Typ String?
Velikost String?
Xvel String @id
}

model vfaktury {
idDok Int
idFakt Int @default(autoincrement()) @id
idZak Int?
vfCCelkem Float?
vfCCelkemS Float?
vfCisPoh String?
vfDFakt DateTime?
vfDPH Int?
vfDUZP DateTime?
vfPozn String?
vfSplatnost Int?
vfStav String?
vfText String?
dokumenty dokumenty @relation(fields: [idDok], references: [idDok])
zakazky zakazky? @relation(fields: [idZak], references: [idZak])
vfakturyp vfakturyp[]

@@index([idDok], name: "faktura_doc_idx")
@@index([idZak], name: "faktura_zak_idx")
}

model vfakturyp {
idFakt Int
idfPol Int
vfpCena Float?
vfpCena1 Float?
vfpFrekv Int?
vfpJedn String?
vfpPocet Int?
vfpText String?
vfaktury vfaktury @relation(fields: [idFakt], references: [idFakt])

@@id([idFakt, idfPol])
}

model vylepy {
dDodani DateTime?
dExpedice DateTime?
dVylep DateTime?
idObdobi Int
idSkup Int?
idTiskarny Int?
idZak Int
Material String?
Reference String?
tiskarny tiskarny? @relation(fields: [idTiskarny], references: [idTiskarny])
zakobdobi zakobdobi @relation(fields: [idZak, idObdobi], references: [idZak, idObdobi])

@@index([idTiskarny], name: "vylep_tiskarna_idx")
@@unique([idZak, idObdobi, idSkup], name: "idZakObdSkup_UNIQUE")
}

model zakazky {
DPrac DateTime?
Firma Int @default(1)
idDokFakt Int?
idKlient Int
idKraj Int?
idNadObdobi Int?
idOsoby Int
idZak Int @default(autoincrement()) @id
idZakRodic Int?
idzDir Int?
Mesto String?
Stav String
zEdit Int @default(0)
zKorp zakazky_zKorp @default(normal)
zMena mena @default(kc)
ZNazev String
zOpce Int?
ZTyp String?
zVazba zakazky_zVazba?
firmy firmy @relation(fields: [idKlient], references: [idFirmy])
nadobdobi nadobdobi? @relation(fields: [idNadObdobi], references: [idObdobi])
osoby osoby @relation(fields: [idOsoby], references: [idOsoby])
zakazky zakazky? @relation("zakazkyTozakazky_idZakRodic", fields: [idZakRodic], references: [idZak])
dir dir? @relation(fields: [idzDir], references: [idDir])
alarm alarm[]
dokumenty dokumenty[]
motivy motivy[]
svoobdobi svoobdobi[]
undozak undozak[]
vfaktury vfaktury[]
other_zakazky zakazky[] @relation("zakazkyTozakazky_idZakRodic")
zakazkyp zakazkyp[]
zakdok zakdok[]
zakloga zakloga[]
zakobdobi zakobdobi[]
zakprefakt zakprefakt[]
zakprod zakprod[]

@@index([Firma], name: "Firma")
@@index([ZTyp, idKlient], name: "Korporatni Navigace")
@@index([idzDir], name: "zakazka_dir_idx")
@@index([idKlient], name: "zakazka_klient_idx")
@@index([idNadObdobi], name: "zakazka_nadobdobi_idx")
@@index([idOsoby], name: "zakazka_osoba_idx")
@@index([idZakRodic], name: "zakazka_rodic_idx")
}

model zakazkyp {
idAgent Int?
idZak Int
Info String?
kStrid Int?
kVyznam Int?
mDesek Int?
NCena Int?
NCis Int
PCis Int
PMotiv Int? @default(1)
PTyp String
Sipka String?
Strany Int? @default(1)
Vzdalenost String?
nosice nosice @relation(fields: [NCis], references: [NCis])
firmy firmy? @relation(fields: [idAgent], references: [idFirmy])
zakazky zakazky @relation(fields: [idZak], references: [idZak])
fotogr fotogr[]
zaknos zaknos[]
zakpkorp zakpkorp[]

@@id([idZak, NCis])
@@index([idAgent], name: "zakp_agent_idx")
@@index([NCis], name: "zakp_ncis_idx")
@@unique([idZak, PTyp, PCis], name: "pcis")
}

model zakdok {
idDok Int
idZak Int
zdCena Float?
zdTyp String? @default("D")
dokumenty dokumenty @relation(fields: [idDok], references: [idDok])
zakazky zakazky @relation(fields: [idZak], references: [idZak])

@@id([idDok, idZak])
@@index([idZak], name: "doc_zak_idx")
}

model zakloga {
idLogo Int
idZak Int
loga loga @relation(fields: [idLogo], references: [idLogo])
zakazky zakazky @relation(fields: [idZak], references: [idZak])

@@id([idZak, idLogo])
@@index([idLogo], name: "zak_logo_idx")
}

model zaknos {
Aud Int @default(0)
idObdobi Int
idZak Int
Motiv Int? @default(1)
ncis Int
Obsaz String @default("")
PCena Int?
Pocet Int @default(1)
TCena Int?
X Int @default(0)
XZ Int @default(0)
motivy motivy? @relation(fields: [Motiv], references: [Motiv])
nosskup_nosskupTozaknos_idObdobi_ncis nosskup @relation("nosskupTozaknos_idObdobi_ncis", fields: [idObdobi, ncis], references: [idObdobi, ncis])
zakobdobi zakobdobi @relation(fields: [idZak, idObdobi], references: [idZak, idObdobi])
zakazkyp zakazkyp @relation(fields: [idZak, ncis], references: [idZak, NCis])
fotodoc fotodoc[]
nabzak nabzak[]
nosskup_nosskup_idZak_idObdobi_ncisTozaknos nosskup[] @relation("nosskup_idZak_idObdobi_ncisTozaknos")
zaknosprod zaknosprod[]
zakrez zakrez[]

@@id([idZak, idObdobi, ncis])
@@index([idZak, idObdobi], name: "IDZak & IDObdobi")
@@index([idZak, ncis], name: "IDZak & ncis")
@@index([Motiv], name: "zaknos_motiv")
@@index([idObdobi, ncis], name: "zaknos_skup_idx")
}

model zaknosprod {
idObdobi Int
idProdukce Int
idZak Int
ks Int @default(1)
ncis Int
val Int?
produkce produkce @relation(fields: [idProdukce], references: [idProdukce])
zaknos zaknos @relation(fields: [idZak, idObdobi, ncis], references: [idZak, idObdobi, ncis])

@@id([idZak, idObdobi, ncis, idProdukce])
@@index([idProdukce], name: "zaknosprod_prod_idx")
}

model zakobdobi {
DCena Int?
idObdobi Int
idZak Int
Poradi Int?
obdobi obdobi @relation(fields: [idObdobi], references: [idObdobi])
zakazky zakazky @relation(fields: [idZak], references: [idZak])
mapperitem mapperitem[]
vylepy vylepy[]
zaknos zaknos[]
zakostatni zakostatni[]

@@id([idZak, idObdobi])
@@index([idObdobi], name: "zak_obdobi")
}

model zakostatni {
idObdobi Int
idZak Int
zoCena Int?
zoDFakt DateTime?
zoJednotka String?
zoPocet Int?
zoText String?
zakobdobi zakobdobi @relation(fields: [idZak, idObdobi], references: [idZak, idObdobi])

@@id([idZak, idObdobi])
}

model zakpkorp {
cTabPrel Int?
cTisk Int?
cVylep Int?
idAgent Int?
idZak Int
ncis Int
SAPobj Int?
VlastTab String?
firmy firmy? @relation(fields: [idAgent], references: [idFirmy])
zakazkyp zakazkyp @relation(fields: [idZak, ncis], references: [idZak, NCis])

@@id([idZak, ncis])
@@index([idAgent], name: "zakkorp_agent_idx")
}

model zakprefakt {
idZak Int @id
SpecDet String?
Specifikace String?
zpFixNakl Int?
zpFrekvence Int?
zpJednatel Int?
zpKlJednatel Int?
zpSplatnost Int?
zakazky zakazky @relation(fields: [idZak], references: [idZak])
}

model zakprod {
idProd Int
idZak Int
prodejny prodejny @relation(fields: [idProd], references: [idProd])
zakazky zakazky @relation(fields: [idZak], references: [idZak])

@@id([idZak, idProd])
@@index([idProd], name: "prod_zak_idx")
}

model zakrez {
idObdobi Int
idZak Int
ncis Int
rOpce Int?
rPoradi Int
zaknos zaknos @relation(fields: [idZak, idObdobi, ncis], references: [idZak, idObdobi, ncis])

@@id([idZak, idObdobi, ncis])
}

model zaksoubory {
fdate DateTime?
fext String
fname String
fSize Int?
idOsoby Int
osoby osoby @relation(fields: [idOsoby], references: [idOsoby])

@@id([fname, fext, idOsoby])
@@index([idOsoby], name: "zaksoubor_osoba_idx")
}

enum auditnos_aStav {
OK
Vada
Urgentn_ @map("Urgentní")
}

enum mena {
kc @map("Kč")
eur @map("€")
centi_eur @map("c€")
}

enum dokumenty_dokNeurcita {
neur_it_ @map("neurčitá")
AP
opce
}

enum firmy_fKat {
Politika
Alkohol
Potraviny
N_bytek @map("Nábytek")
Sex
Kasino
ostatn_ @map("ostatní")
}

enum korposoby_Funkce {
admin
GL
VL
GF
VKL
VP
}

enum loga_skupina {
potraviny
n_bytek @map("nábytek")
hobby
}

enum motivy_mSkup {
Kam
Nav
SVO
}

enum nadobdobi_noTyp {
m
A
}

enum svo_svoPoloha {
vpravo
st_ed @map("střed")
vlevo
vlevo_4p @map("vlevo 4p")
}

enum svo_svoPozice {
prav_ @map("pravá")
st_ed @map("střed")
lev_ @map("levá")
z_da_prav_ @map("záda pravá")
z_da_st_ed @map("záda střed")
z_da_lev_ @map("záda levá")
}

enum svoobdobi_svoStav {
bal__ek @map("balíček")
pron_jem @map("pronájem")
rezervace
ciz_ @map("cizí")
voln_ @map("volná")
}

enum svoobdobi_svoTyp {
B_flex @map("B flex")
C_flex @map("C flex")
}

enum zakazky_zKorp {
normal
prodejny
korporace
}

enum zakazky_zVazba {
kopie
pokra_ov_n_ @map("pokračování")
agentura
korp_agent @map("korp agent")
}

@theRocket
Copy link

I don't think Prisma 1 set up my enums as a column property in MySQL, so I had to add those back after an introspection. Now, I think if I introspected, it might find them. I also switched from MySQL 5.7 to 8 (the main impetus for upgrading the Prisma 2, the timing of the G.A. was just fortuitous), so I'm not sure where that enum feature evolved exactly.

@janpio
Copy link
Member

janpio commented Jun 11, 2020

@theRocket I am happy to investigate this in more detail and possibly give you some pointers (we have an upgrade tool for P1->P2 for example) - best create an issue and link to it here (or @ mention me).

@theRocket
Copy link

Thanks, @janpio. I did use the prisma-upgrade tool, but I think I may have discovered it after already running one introspection. That tool has good instructions for the correct order of operation, but I think that first introspect dropped the enums since 5.7 didn't have them in schema. I have all this in branches and containers, so I could reproduce it.

@janpio
Copy link
Member

janpio commented Jun 11, 2020

Sweet, just post the issue link here then after creating it and we can take a deeper look.

@louisrli
Copy link

I think I ran into this issue as well with IDs. Basically after a second re-introspection of a postgres database, this happened to all my IDs:

-  id                                    String          @default(cuid()) @id
+  id                                    String          @id

this to my timestamps:

-  createdTimestamp        DateTime           @default(now())
+  createdTimestamp        DateTime

-  updatedTimestamp DateTime          @updatedAt
+  updatedTimestamp DateTime

which I don't think is what I want...

@louisrli
Copy link

louisrli commented Jun 14, 2020

I think it's related to this one (and the one below)
https://www.prisma.io/docs/guides/upgrade-from-prisma-1/schema-incompatibilities-postgres#generated-cuids-as-id-values-arent-represented-in-database

but it's be really nice if introspection could be smart enough to leave any @id annotations with the same column name untouched if there's such additional annotations, I do see that it says "Note that you'll have to re-add the attribute after each introspection because introspection removes it (as the previous version of the Prisma schema is overwritten)!"

@janpio
Copy link
Member

janpio commented Jun 14, 2020

If you could send us your SQL and Prisma schemas to schemas@prisma.io that would be great - then we will add your schema to our CI system that will make sure we get better on this over time @louisrli 👍

@Akxe
Copy link
Contributor

Akxe commented Jun 19, 2020

@janpio @do4gr Do you need anything other than what I provided?

@harryttd
Copy link

harryttd commented Jun 30, 2020

EDIT: I am using the --experimental-reintrospection flag.

For id field, original introspection yields: id String @default(dbgenerated()) @id.
I modified it to be id String @default(uuid()) @id.
Re-introspecting brings it back to id String @default(dbgenerated()) @id.

Also, I believe it was mentioned in another issue, but I need to manually set @updatedAt on the updatedAt column as it is not set by the original introspection. Re-introspecting removes it.

@janpio
Copy link
Member

janpio commented Jun 30, 2020

⚠️ We shipped an initial version of Re-Introspection behind a feature flag: #2829 This will only cover some of your use cases, but maybe try it out and report back to us if it does solve one of your problems or if you encounter any (new) bugs. Thanks!

@divyenduz
Copy link
Contributor

@harryttd Can you please share the SQL and the database (Postgres or MySQL?) that you are using?

@Akxe Akxe mentioned this issue Jun 30, 2020
7 tasks
@harryttd
Copy link

harryttd commented Jun 30, 2020

@janpio Apologies, I neglected to mention that I am using the --experimental-reintrospection.

EDIT: Created issue

@janpio

This comment has been minimized.

@janpio
Copy link
Member

janpio commented Aug 17, 2020

All your Re-Introspection problems fixed with what we released in #2711 (comment)? If not, please open a new issue so we can discuss the problem and find a solution.

@janpio janpio closed this as completed Aug 17, 2020
@divyenduz divyenduz unpinned this issue Aug 18, 2020
@janpio
Copy link
Member

janpio commented Aug 20, 2020

Big update over at #2829 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement An improvement to existing feature and code. topic: re-introspection
Projects
None yet
Development

No branches or pull requests

7 participants