@tanglemedia/directus-collection-embed
Version:
Installs the Embed Collection to your Directus project.
34 lines (25 loc) • 798 B
JavaScript
const COLLECTION_NAME = "tngl_embed";
export async function up(knex) {
// if table exists, do not proceed with migration
if (await knex.schema.hasTable(COLLECTION_NAME)) {
return;
}
// create table
await knex.schema.createTable(COLLECTION_NAME, (table) => {
table.increments("id").unsigned().notNullable();
// default fields
table.integer("sort").nullable();
// custom fields
table.string("title", 255).nullable();
table.string("type", 255).nullable().defaultTo("general");
// embed attributes
table.string("youtube_id", 255).nullable();
// generic embed
table.text("embed_code").nullable();
table.primary(["id"]);
});
}
export async function down(knex) {
// drop table
await knex.schema.dropTableIfExists(COLLECTION_NAME);
}