addSql(<<<'SQL' CREATE TABLE actions (id SERIAL NOT NULL, users_id INT DEFAULT NULL, action_type VARCHAR(255) NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id)) SQL); $this->addSql(<<<'SQL' CREATE UNIQUE INDEX UNIQ_548F1EF67B3B43D ON actions (users_id) SQL); $this->addSql(<<<'SQL' COMMENT ON COLUMN actions.date IS '(DC2Type:datetime_immutable)' SQL); $this->addSql(<<<'SQL' CREATE TABLE apps (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, sub_domain VARCHAR(255) NOT NULL, logo_url VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, is_active BOOLEAN DEFAULT true NOT NULL, PRIMARY KEY(id)) SQL); $this->addSql(<<<'SQL' CREATE TABLE apps_organizations (apps_id INT NOT NULL, organizations_id INT NOT NULL, PRIMARY KEY(apps_id, organizations_id)) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_FFE659D5A2D76671 ON apps_organizations (apps_id) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_FFE659D586288A55 ON apps_organizations (organizations_id) SQL); $this->addSql(<<<'SQL' CREATE TABLE cgu (id SERIAL NOT NULL, version VARCHAR(20) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id)) SQL); $this->addSql(<<<'SQL' COMMENT ON COLUMN cgu.created_at IS '(DC2Type:datetime_immutable)' SQL); $this->addSql(<<<'SQL' CREATE TABLE cgu_user (id SERIAL NOT NULL, users_id INT NOT NULL, cgu_id INT NOT NULL, is_accepted BOOLEAN DEFAULT false NOT NULL, PRIMARY KEY(id)) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_382CC76767B3B43D ON cgu_user (users_id) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_382CC767D1513B86 ON cgu_user (cgu_id) SQL); $this->addSql(<<<'SQL' CREATE TABLE organizations (id SERIAL NOT NULL, email VARCHAR(255) NOT NULL, number INT NOT NULL, address VARCHAR(255) NOT NULL, logo_url VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, is_deleted BOOLEAN DEFAULT false NOT NULL, is_active BOOLEAN DEFAULT true NOT NULL, PRIMARY KEY(id)) SQL); $this->addSql(<<<'SQL' COMMENT ON COLUMN organizations.created_at IS '(DC2Type:datetime_immutable)' SQL); $this->addSql(<<<'SQL' CREATE TABLE roles (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id)) SQL); $this->addSql(<<<'SQL' COMMENT ON COLUMN roles.created_at IS '(DC2Type:datetime_immutable)' SQL); $this->addSql(<<<'SQL' CREATE TABLE users_organizations (id SERIAL NOT NULL, users_id INT NOT NULL, organization_id INT NOT NULL, role_id INT NOT NULL, is_active BOOLEAN DEFAULT true NOT NULL, PRIMARY KEY(id)) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_4B99147267B3B43D ON users_organizations (users_id) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_4B99147232C8A3DE ON users_organizations (organization_id) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_4B991472D60322AC ON users_organizations (role_id) SQL); $this->addSql(<<<'SQL' CREATE TABLE users_organizations_apps (users_organizations_id INT NOT NULL, apps_id INT NOT NULL, PRIMARY KEY(users_organizations_id, apps_id)) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_F01F6897964985F0 ON users_organizations_apps (users_organizations_id) SQL); $this->addSql(<<<'SQL' CREATE INDEX IDX_F01F6897A2D76671 ON users_organizations_apps (apps_id) SQL); $this->addSql(<<<'SQL' ALTER TABLE actions ADD CONSTRAINT FK_548F1EF67B3B43D FOREIGN KEY (users_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE apps_organizations ADD CONSTRAINT FK_FFE659D5A2D76671 FOREIGN KEY (apps_id) REFERENCES apps (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE apps_organizations ADD CONSTRAINT FK_FFE659D586288A55 FOREIGN KEY (organizations_id) REFERENCES organizations (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE cgu_user ADD CONSTRAINT FK_382CC76767B3B43D FOREIGN KEY (users_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE cgu_user ADD CONSTRAINT FK_382CC767D1513B86 FOREIGN KEY (cgu_id) REFERENCES cgu (id) NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations ADD CONSTRAINT FK_4B99147267B3B43D FOREIGN KEY (users_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations ADD CONSTRAINT FK_4B99147232C8A3DE FOREIGN KEY (organization_id) REFERENCES organizations (id) NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations ADD CONSTRAINT FK_4B991472D60322AC FOREIGN KEY (role_id) REFERENCES roles (id) NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations_apps ADD CONSTRAINT FK_F01F6897964985F0 FOREIGN KEY (users_organizations_id) REFERENCES users_organizations (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations_apps ADD CONSTRAINT FK_F01F6897A2D76671 FOREIGN KEY (apps_id) REFERENCES apps (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" ADD name VARCHAR(255) NOT NULL SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" ADD surname VARCHAR(255) NOT NULL SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" ADD picture_url VARCHAR(255) NOT NULL SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" ADD modified_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" ADD is_active BOOLEAN DEFAULT true NOT NULL SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" ADD is_deleted BOOLEAN DEFAULT false NOT NULL SQL); $this->addSql(<<<'SQL' COMMENT ON COLUMN "user".created_at IS '(DC2Type:datetime_immutable)' SQL); $this->addSql(<<<'SQL' COMMENT ON COLUMN "user".modified_at IS '(DC2Type:datetime_immutable)' SQL); } public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->addSql(<<<'SQL' CREATE SCHEMA public SQL); $this->addSql(<<<'SQL' ALTER TABLE actions DROP CONSTRAINT FK_548F1EF67B3B43D SQL); $this->addSql(<<<'SQL' ALTER TABLE apps_organizations DROP CONSTRAINT FK_FFE659D5A2D76671 SQL); $this->addSql(<<<'SQL' ALTER TABLE apps_organizations DROP CONSTRAINT FK_FFE659D586288A55 SQL); $this->addSql(<<<'SQL' ALTER TABLE cgu_user DROP CONSTRAINT FK_382CC76767B3B43D SQL); $this->addSql(<<<'SQL' ALTER TABLE cgu_user DROP CONSTRAINT FK_382CC767D1513B86 SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations DROP CONSTRAINT FK_4B99147267B3B43D SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations DROP CONSTRAINT FK_4B99147232C8A3DE SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations DROP CONSTRAINT FK_4B991472D60322AC SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations_apps DROP CONSTRAINT FK_F01F6897964985F0 SQL); $this->addSql(<<<'SQL' ALTER TABLE users_organizations_apps DROP CONSTRAINT FK_F01F6897A2D76671 SQL); $this->addSql(<<<'SQL' DROP TABLE actions SQL); $this->addSql(<<<'SQL' DROP TABLE apps SQL); $this->addSql(<<<'SQL' DROP TABLE apps_organizations SQL); $this->addSql(<<<'SQL' DROP TABLE cgu SQL); $this->addSql(<<<'SQL' DROP TABLE cgu_user SQL); $this->addSql(<<<'SQL' DROP TABLE organizations SQL); $this->addSql(<<<'SQL' DROP TABLE roles SQL); $this->addSql(<<<'SQL' DROP TABLE users_organizations SQL); $this->addSql(<<<'SQL' DROP TABLE users_organizations_apps SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" DROP name SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" DROP surname SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" DROP created_at SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" DROP picture_url SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" DROP modified_at SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" DROP is_active SQL); $this->addSql(<<<'SQL' ALTER TABLE "user" DROP is_deleted SQL); } }