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')