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


class CreateCrossReferencesTable(Migration):

    def up(self):
        """
        Run the migrations.
        """
        with self.schema.create('crossreferences') as table:
            table.integer('passage_id1')
            table.integer('passage_id2')
            table.timestamps()
            table.small_integer('relevance').default(0)
            table.foreign('passage_id1').references('id').on('passages')
            table.foreign('passage_id2').references('id').on('passages')
            table.primary(['passage_id1', 'passage_id2'])

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