blob: a044dbbfa354f77e917d52dd62a50a87f8e7798f (
plain) (
blame)
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
|
from orator.migrations import Migration
class CreatePassagesTable(Migration):
def up(self):
"""
Run the migrations.
"""
with self.schema.create('passages') as table:
table.increments('id')
table.string('fst_book')
table.small_integer('fst_chapter')
table.small_integer('fst_nr')
table.string('snd_book')
table.small_integer('snd_chapter')
table.small_integer('snd_nr')
table.foreign(['fst_book', 'fst_chapter', 'fst_nr'])\
.references(['book', 'chapter', 'nr']).on('verses')\
.on_delete('restrict').on_update('cascade')
table.foreign(['snd_book', 'snd_chapter', 'snd_nr'])\
.references(['book', 'chapter', 'nr']).on('verses')\
.on_delete('restrict').on_update('cascade')
table.unique(['fst_book', 'fst_chapter', 'fst_nr',
'snd_book', 'snd_chapter', 'snd_nr'])
def down(self):
"""
Revert the migrations.
"""
self.schema.drop('passages')
|