|  | 
|  | 1 | +<?php | 
|  | 2 | + | 
|  | 3 | +declare(strict_types=1); | 
|  | 4 | + | 
|  | 5 | +namespace DoctrineMigrations; | 
|  | 6 | + | 
|  | 7 | +use Doctrine\DBAL\Schema\Schema; | 
|  | 8 | +use Doctrine\Migrations\AbstractMigration; | 
|  | 9 | + | 
|  | 10 | +/** | 
|  | 11 | + * Auto-generated Migration: Please modify to your needs! | 
|  | 12 | + */ | 
|  | 13 | +final class Version20251004093025 extends AbstractMigration { | 
|  | 14 | +    public function getDescription(): string { | 
|  | 15 | +        return ''; | 
|  | 16 | +    } | 
|  | 17 | + | 
|  | 18 | +    public function up(Schema $schema): void { | 
|  | 19 | +        // this up() migration is auto-generated, please modify it to your needs | 
|  | 20 | +        $this->addSql('ALTER TABLE camp ADD isPublic BOOLEAN DEFAULT false NOT NULL'); | 
|  | 21 | +        $this->addSql('UPDATE camp SET isPublic = (isShared OR isPrototype)'); | 
|  | 22 | +        $this->addSql('ALTER TABLE camp ADD CONSTRAINT enforce_public_flag CHECK (isPublic = (isShared OR isPrototype))'); | 
|  | 23 | +        $this->addSql('CREATE INDEX IDX_C1944230FADC24C7 ON camp (isPublic)'); | 
|  | 24 | +        $this->addSql( | 
|  | 25 | +            <<<'EOF' | 
|  | 26 | +                    CREATE OR REPLACE VIEW public.view_user_camps | 
|  | 27 | +                    AS | 
|  | 28 | +                    SELECT CONCAT(u.id, c.id) id, u.id userid, c.id campid | 
|  | 29 | +                    from camp c, "user" u | 
|  | 30 | +                    where c.ispublic = TRUE | 
|  | 31 | +                    union all | 
|  | 32 | +                    select	cc.id, cc.userid, cc.campid | 
|  | 33 | +                    from	camp_collaboration cc | 
|  | 34 | +                    where 	cc.status = 'established' | 
|  | 35 | +                EOF | 
|  | 36 | +        ); | 
|  | 37 | +    } | 
|  | 38 | + | 
|  | 39 | +    public function down(Schema $schema): void { | 
|  | 40 | +        // this down() migration is auto-generated, please modify it to your needs | 
|  | 41 | +        $this->addSql( | 
|  | 42 | +            <<<'EOF' | 
|  | 43 | +                    CREATE OR REPLACE VIEW public.view_user_camps | 
|  | 44 | +                    AS | 
|  | 45 | +                    SELECT CONCAT(u.id, c.id) id, u.id userid, c.id campid | 
|  | 46 | +                    from camp c, "user" u | 
|  | 47 | +                    where c.isprototype = TRUE or c.isshared = TRUE | 
|  | 48 | +                    union all | 
|  | 49 | +                    select	cc.id, cc.userid, cc.campid | 
|  | 50 | +                    from	camp_collaboration cc | 
|  | 51 | +                    where 	cc.status = 'established' | 
|  | 52 | +                EOF | 
|  | 53 | +        ); | 
|  | 54 | +        $this->addSql('DROP INDEX IDX_C1944230FADC24C7'); | 
|  | 55 | +        $this->addSql('ALTER TABLE camp DROP CONSTRAINT enforce_public_flag'); | 
|  | 56 | +        $this->addSql('ALTER TABLE camp DROP isPublic'); | 
|  | 57 | +    } | 
|  | 58 | +} | 
0 commit comments