-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate.py
More file actions
38 lines (33 loc) · 1.06 KB
/
migrate.py
File metadata and controls
38 lines (33 loc) · 1.06 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
import os
from sqlite3 import connect
import sentry_sdk
from sentry_sdk.integrations.pure_eval import PureEvalIntegration
sentry_sdk.init(
debug=True,
integrations=[
PureEvalIntegration(),
],
traces_sample_rate=1.0,
attach_stacktrace=True,
max_request_body_size="always",
in_app_include=[
"checkpoint",
],
profiles_sample_rate=1.0,
)
db = connect(os.environ["FLASK_DATABASE_LOCATION"])
db.execute("PRAGMA foreign_keys = 1")
db.executescript("""
CREATE TABLE IF NOT EXISTS crosswalk (
gt_person_directory_id TEXT NOT NULL PRIMARY KEY COLLATE NOCASE,
gtid INTEGER NOT NULL UNIQUE,
primary_username TEXT NOT NULL UNIQUE COLLATE NOCASE,
keycloak_user_id TEXT UNIQUE COLLATE NOCASE,
google_workspace_user_id TEXT UNIQUE COLLATE NOCASE
) strict;
CREATE TABLE IF NOT EXISTS crosswalk_email_address (
email_address TEXT NOT NULL PRIMARY KEY COLLATE NOCASE,
gt_person_directory_id TEXT NOT NULL COLLATE NOCASE,
FOREIGN KEY(gt_person_directory_id) REFERENCES crosswalk(gt_person_directory_id)
) strict;
""")