50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Migration: Add embed asset support
|
|
*
|
|
* Adds support for storing embed assets (360 panoramas, 3D models, iframes):
|
|
* - Add 'embed' to asset_type ENUM
|
|
* - Add embed types to type ENUM (embed_360, embed_3d, embed_iframe)
|
|
* - Add embed_code column (stores full iframe HTML or direct URL)
|
|
* - Add embed_provider column (extracted provider name: matterport, kuula, etc.)
|
|
*/
|
|
|
|
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
// Add 'embed' to asset_type ENUM
|
|
await queryInterface.sequelize.query(`
|
|
ALTER TYPE "enum_assets_asset_type" ADD VALUE IF NOT EXISTS 'embed';
|
|
`);
|
|
|
|
// Add embed types to type ENUM (categories)
|
|
await queryInterface.sequelize.query(`
|
|
ALTER TYPE "enum_assets_type" ADD VALUE IF NOT EXISTS 'embed_360';
|
|
`);
|
|
await queryInterface.sequelize.query(`
|
|
ALTER TYPE "enum_assets_type" ADD VALUE IF NOT EXISTS 'embed_3d';
|
|
`);
|
|
await queryInterface.sequelize.query(`
|
|
ALTER TYPE "enum_assets_type" ADD VALUE IF NOT EXISTS 'embed_iframe';
|
|
`);
|
|
|
|
// Add embed_code column (stores full iframe HTML or direct URL)
|
|
await queryInterface.addColumn('assets', 'embed_code', {
|
|
type: Sequelize.TEXT,
|
|
allowNull: true,
|
|
});
|
|
|
|
// Add embed_provider column (extracted: 'matterport', 'kuula', etc.)
|
|
await queryInterface.addColumn('assets', 'embed_provider', {
|
|
type: Sequelize.TEXT,
|
|
allowNull: true,
|
|
});
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
await queryInterface.removeColumn('assets', 'embed_code');
|
|
await queryInterface.removeColumn('assets', 'embed_provider');
|
|
// Note: PostgreSQL doesn't support removing ENUM values
|
|
},
|
|
};
|