forked from mozilla-services/socorro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
72 lines (36 loc) · 1.58 KB
/
README
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
= Using Alembic for schema migrations =
To use Alembic for your next schema change:
Enable your virtualenv.
Create an initial database using setupdb_app.py. See the Makefile for examples of usage.
Make a change to:
socorro/external/postgresql/models.py
And then:
PYTHONPATH=. alembic revision --autogenerate -m "Making an important change to the schema"
A migration script will be put into:
alembic/versions
Now you can modify it to meet your needs.
Then, to apply the migration:
PYTHONPATH=. alembic upgrade heads
Downgrade to previous revision:
PYTHONPATH=. alembic downgrade -1
== Dealing with unsupported or custom TYPEs ==
We use a few types not currently supported by SQLAlchemy, so you may
need to modify the migration slightly.
== Helper functions in socorro.lib.migrations
We have a couple helper functions for doing cleanup tasks, and adding custom
types. These functions and classes are imported by the default template for
a migration.
=== Fixing permissions after adding a table
This is hardcoded to change the owner of a table to `breakpad_rw`.
Example:
fix_permissions(op, u'tablename')
=== Loading a new stored proc
Example:
load_stored_proc(op, ['update_matviews.sql', 'backfill_matviews.sql'])
=== JSON datatype example
Modify to import JSON type from socorro's model:
sa.Column(u'raw_crash', jsontype.JsonType(), nullable=False),
=== CITEXT datatype example
sa.Column(u'new_stuff', citexttype.CitextType(), nullable=False),
== Adding an index
sa.Column(u'uuid', postgresql.UUID(), nullable=False, index=True, unique=True),