-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathVersion20250903154700.php
More file actions
56 lines (50 loc) · 1.88 KB
/
Version20250903154700.php
File metadata and controls
56 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250903154700 extends AbstractMigration {
public function getDescription(): string {
return 'Add another view for filtering out person-related data in public camps';
}
public function up(Schema $schema): void {
$this->addSql(
<<<'EOF'
CREATE OR REPLACE VIEW public.view_user_camps
AS
select cc.id::TEXT, cc.userid, cc.campid
from camp_collaboration cc
where cc.status = 'established'
EOF
);
$this->addSql(
<<<'EOF'
CREATE OR REPLACE VIEW public.view_user_camps_with_public
AS
SELECT CONCAT(u.id, c.id) id, u.id userid, c.id campid
from camp c, "user" u
where c.isprototype = TRUE or c.isshared = TRUE
union all
select cc.id, cc.userid, cc.campid
from camp_collaboration cc
where cc.status = 'established'
EOF
);
}
public function down(Schema $schema): void {
$this->addSql('DROP VIEW IF EXISTS public.view_user_camps_with_public');
$this->addSql(
<<<'EOF'
CREATE OR REPLACE VIEW public.view_user_camps
AS
SELECT CONCAT(u.id, c.id) id, u.id userid, c.id campid
from camp c, "user" u
where c.isprototype = TRUE
union all
select cc.id, cc.userid, cc.campid
from camp_collaboration cc
where cc.status = 'established'
EOF
);
}
}