Skip to content
Snippets Groups Projects
20211208000001-create-classification-roots-table.js 1015 B
Newer Older
module.exports = {
	up: (migration, Types) => {
		return migration.createTable('classification_roots', {
			metric_id: {
				type: Types.UUID,
				allowNull: false,
				unique: true,
				primaryKey: true,
			},
			upload_id: {
				type: Types.UUID,
				allowNull: false,
				references: {
					model: 'uploads',
					key: 'id',
				},
			},
			image_id: {
				type: Types.UUID,
				allowNull: false,
			},
			url: {
				type: Types.TEXT,
				allowNull: false,
			},
			status: {
				type: Types.TEXT,
				allowNull: false,
				defaultValue: 'pending',
			},
			meta: {
				type: Types.JSONB,
				defaultValue: {},
				allowNull: false,
			},
			created_at: {
				type: Types.DATE,
				defaultValue: Types.fn('now'),
				allowNull: false,
			},
			updated_at: {
				type: Types.DATE,
				defaultValue: Types.fn('now'),
				allowNull: false,
			},
			deleted_at: {
				type: Types.DATE,
				defaultValue: null,
				allowNull: true,
			},
		})
	},

	down: (migration, Types) => {
		return migration.dropTable('')
	},
}