Upgrades
[cas.git] / src / emails / migrations / 0005_create_view.py
1 # Generated by Django 4.2.16 on 2026-08-28 12:48
2
3 from django.db import migrations
4
5
6 CREATE_VIEW = """
7 CREATE VIEW emails_sharedmailbox_v AS
8 SELECT
9     sm.name     AS from_user,
10     u.username  AS to_user
11 FROM emails_sharedmailbox_users g
12 JOIN auth_user u ON u.id = g.user_id
13 JOIN emails_sharedmailbox sm  ON sm.id = g.sharedmailbox_id;
14 """
15
16 DROP_VIEW = "DROP VIEW IF EXISTS emails_sharedmailbox_v;"
17
18
19 class Migration(migrations.Migration):
20
21     dependencies = [
22         ('emails', '0004_sharedmailbox'),
23     ]
24
25     operations = [
26         migrations.RunSQL(CREATE_VIEW, reverse_sql=DROP_VIEW),
27     ]