aboutsummaryrefslogtreecommitdiff
path: root/migrations/2015_10_14_17201444836054_create_translated_verses_table.py
blob: 43703e302f5fdbbfecaecd751847c640d200d689 (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
from orator.migrations import Migration


class CreateTranslatedVersesTable(Migration):

    def up(self):
        """
        Run the migrations.
        """
        with self.schema.create('translated_verses') as table:
            table.string('translation')
            table.string('book')
            table.small_integer('chapter')
            table.small_integer('nr')
            table.string('text')
            table.foreign('translation').references('name').on('translations')
            table.foreign(['book', 'chapter', 'nr'])\
                    .references(['book', 'chapter', 'nr']).on('verses')\
                    .on_delete('restrict').on_update('cascade')
            table.primary(['translation', 'book', 'chapter', 'nr'])

    def down(self):
        """
        Revert the migrations.
        """
        self.schema.drop('translated_verses')