$this->addSql('CREATE TABLE audit (id INT NOT NULL, entityname VARCHAR(250) NOT NULL, entityid VARCHAR(250) NOT NULL, datesubmit TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, username VARCHAR(250) NOT NULL, description TEXT DEFAULT NULL, detail TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX search_idx ON audit (entityname, entityid, datesubmit)');
$this->addSql('COMMENT ON COLUMN audit.detail IS \'(DC2Type:array)\'');
$this->addSql('CREATE TABLE config (id VARCHAR(255) NOT NULL, title VARCHAR(250) NOT NULL, value TEXT DEFAULT NULL, defaultvalue TEXT NOT NULL, roworder VARCHAR(255) NOT NULL, visible BOOLEAN NOT NULL, changeable BOOLEAN NOT NULL, required BOOLEAN NOT NULL, type VARCHAR(255) NOT NULL, grouped VARCHAR(255) NOT NULL, category VARCHAR(255) NOT NULL, help TEXT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE cron (id INT NOT NULL, command VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, statut INT DEFAULT NULL, submitdate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, startexecdate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, endexecdate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, nextexecdate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, repeatinterval INT DEFAULT NULL, jsonargument TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE groupe (id INT NOT NULL, owner_id INT DEFAULT NULL, label VARCHAR(250) NOT NULL, description TEXT DEFAULT NULL, email VARCHAR(250) DEFAULT NULL, isopen BOOLEAN DEFAULT false NOT NULL, isworkgroup BOOLEAN DEFAULT false NOT NULL, apikey VARCHAR(255) NOT NULL, ldapfilter TEXT DEFAULT NULL, attributes TEXT DEFAULT NULL, idexternal TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_4B98C21EA750E8 ON groupe (label)');
$this->addSql('CREATE INDEX IDX_4B98C217E3C61F9 ON groupe (owner_id)');
$this->addSql('CREATE TABLE niveau01 (id INT NOT NULL, label VARCHAR(250) NOT NULL, code TEXT DEFAULT NULL, postaladress TEXT DEFAULT NULL, telephonenumber VARCHAR(60) DEFAULT NULL, email VARCHAR(60) DEFAULT NULL, apikey VARCHAR(255) NOT NULL, ldapfilter TEXT DEFAULT NULL, attributes TEXT DEFAULT NULL, idexternal TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE niveau02 (id INT NOT NULL, niveau01_id INT NOT NULL, label VARCHAR(250) NOT NULL, code TEXT DEFAULT NULL, postaladress TEXT DEFAULT NULL, telephonenumber VARCHAR(60) DEFAULT NULL, email VARCHAR(60) DEFAULT NULL, apikey VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE niveau03 (id INT NOT NULL, niveau02_id INT NOT NULL, label VARCHAR(250) NOT NULL, code TEXT DEFAULT NULL, postaladress TEXT DEFAULT NULL, telephonenumber VARCHAR(60) DEFAULT NULL, email VARCHAR(60) DEFAULT NULL, apikey VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE niveau04 (id INT NOT NULL, niveau03_id INT NOT NULL, label VARCHAR(250) NOT NULL, code TEXT DEFAULT NULL, postaladress TEXT DEFAULT NULL, telephonenumber VARCHAR(60) DEFAULT NULL, email VARCHAR(60) DEFAULT NULL, apikey VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_1D968AACEA750E8 ON niveau04 (label)');
$this->addSql('CREATE INDEX IDX_1D968AACF3F41F20 ON niveau04 (niveau03_id)');
$this->addSql('CREATE TABLE registration (id INT NOT NULL, niveau01_id INT NOT NULL, niveau02_id INT DEFAULT NULL, niveau03_id INT DEFAULT NULL, niveau04_id INT DEFAULT NULL, username VARCHAR(128) NOT NULL, firstname VARCHAR(250) DEFAULT NULL, lastname VARCHAR(250) DEFAULT NULL, password VARCHAR(250) NOT NULL, salt VARCHAR(250) NOT NULL, email VARCHAR(128) NOT NULL, isvisible BOOLEAN NOT NULL, postaladress VARCHAR(250) DEFAULT NULL, telephonenumber VARCHAR(60) DEFAULT NULL, job VARCHAR(250) DEFAULT NULL, position VARCHAR(250) DEFAULT NULL, motivation TEXT DEFAULT NULL, note TEXT DEFAULT NULL, keyexpire TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, keyvalue VARCHAR(60) DEFAULT NULL, statut INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_62A8A7A7F3F41F20 ON registration (niveau03_id)');
$this->addSql('CREATE INDEX IDX_62A8A7A76E232799 ON registration (niveau04_id)');
$this->addSql('CREATE TABLE useraccount (id INT NOT NULL, niveau01_id INT NOT NULL, niveau02_id INT DEFAULT NULL, niveau03_id INT DEFAULT NULL, niveau04_id INT DEFAULT NULL, username VARCHAR(128) NOT NULL, apikey VARCHAR(255) NOT NULL, firstname VARCHAR(250) DEFAULT NULL, lastname VARCHAR(250) DEFAULT NULL, roles TEXT NOT NULL, password VARCHAR(250) NOT NULL, salt VARCHAR(250) NOT NULL, isactive BOOLEAN NOT NULL, email VARCHAR(128) NOT NULL, avatar VARCHAR(250) DEFAULT \'0\', isvisible BOOLEAN NOT NULL, postaladress TEXT DEFAULT NULL, telephonenumber VARCHAR(60) DEFAULT NULL, job VARCHAR(250) DEFAULT NULL, position VARCHAR(250) DEFAULT NULL, motivation TEXT DEFAULT NULL, note TEXT DEFAULT NULL, preference TEXT DEFAULT NULL, keyexpire TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, keyvalue VARCHAR(60) DEFAULT NULL, visitedate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, visitecpt INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN useraccount.roles IS \'(DC2Type:array)\'');
$this->addSql('COMMENT ON COLUMN useraccount.preference IS \'(DC2Type:array)\'');
$this->addSql('CREATE TABLE usergroupe (id INT NOT NULL, user_id INT DEFAULT NULL, group_id INT DEFAULT NULL, rolegroup INT NOT NULL, apikey VARCHAR(60) NOT NULL, visitedate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, visitecpt INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_6C439BE5A76ED395 ON usergroupe (user_id)');
$this->addSql('CREATE INDEX IDX_6C439BE5FE54D947 ON usergroupe (group_id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_6C439BE5A76ED395FE54D947 ON usergroupe (user_id, group_id)');
$this->addSql('CREATE TABLE usermodo (id INT NOT NULL, user_id INT NOT NULL, niveau01_id INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_D162D6C4A76ED395 ON usermodo (user_id)');
$this->addSql('CREATE INDEX IDX_D162D6C459FDD7AB ON usermodo (niveau01_id)');
$this->addSql('CREATE TABLE whitelist (id INT NOT NULL, label VARCHAR(250) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_CB069864EA750E8 ON whitelist (label)');
$this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
$this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
$this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
$this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
$this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();');
$this->addSql('ALTER TABLE groupe ADD CONSTRAINT FK_4B98C217E3C61F9 FOREIGN KEY (owner_id) REFERENCES useraccount (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');