Last active
January 2, 2016 15:39
-
-
Save peyerluk/8324555 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dropAndRecreateTable = (name, setupMethod) -> | |
knex.schema.dropTableIfExists(name).then -> | |
knex.schema.createTable(name, setupMethod) | |
createDocumentPublicationsTable = (done) -> | |
command = dropAndRecreateTable 'document_publications', (t) -> | |
t.increments('id').primary() | |
t.integer('document_id').notNullable() | |
t.integer('revision_id').notNullable() | |
t.integer('user_id') | |
t.text('html').notNullable() | |
t.string('slug').notNullable() | |
t.integer('publication_number').notNullable() | |
t.dateTime('created_at').notNullable() | |
t.dateTime('updated_at').notNullable() | |
t.unique ['document_id', 'publication_number'], | |
'index_document_publications_on_document_id_and_publication_nr' | |
t.unique ['revision_id', 'document_id'], | |
'index_document_publications_on_revision_id_and_document_id' | |
command.exec(done) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, even refactoring the drop and create :P