from orator.migrations import Migration class CreateAddressesMessagesTable(Migration): def up(self): """ Run the migrations. """ with self.schema.create('addresses_messages') as table: table.integer('message_id').unsigned().references('id').on('messages') table.integer('address_id').unsigned().references('id').on('addresses') table.enum('type', ['to', 'from', 'cc']) table.primary(['message_id', 'address_id', 'type']) def down(self): """ Revert the migrations. """ self.schema.drop('addresses_messages')