Skip to content

Instantly share code, notes, and snippets.

@TheNaoX
Created November 7, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheNaoX/a3945aa9ae2f9f02eca0 to your computer and use it in GitHub Desktop.
Save TheNaoX/a3945aa9ae2f9f02eca0 to your computer and use it in GitHub Desktop.
exports.up = function(knex, Promise) {
return knex.schema.hasTable('short_urls').then(function(exists) {
if (!exists) {
return knex.schema.createTable('short_urls', function(t) {
t.increments('id').primary();
t.text('long_url');
t.string('token', 11);
t.index(['token'], 'short_urls_token_idx')
t.timestamps();
});
}
});
};
exports.down = function(knex, Promise) {
return knex.schema.hasTable('short_urls').then(function(exists) {
if (exists) { knex.schema.dropTable('short_urls') }
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment