package com.jimijon.mwf.migrations;
import com.webobjects.eocontrol.EOEditingContext;
import com.webobjects.foundation.NSArray;
import er.extensions.jdbc.ERXSQLHelper.ColumnIndex;
import er.extensions.migration.ERXMigrationDatabase;
import er.extensions.migration.ERXMigrationIndex;
import er.extensions.migration.ERXMigrationTable;
import er.extensions.migration.ERXModelVersion;
public class MidwestFoodsModel0 extends ERXMigrationDatabase.Migration {
@Override
public NSArray<ERXModelVersion> modelDependencies() {
return null;
}
@Override
public void downgrade(EOEditingContext editingContext, ERXMigrationDatabase database) throws Throwable {
// DO NOTHING
}
@Override
public void upgrade(EOEditingContext editingContext, ERXMigrationDatabase database) throws Throwable {
ERXMigrationTable foodFamilyTable = database.newTableNamed("food_family");
foodFamilyTable.newTimestampColumn("add_date", true);
foodFamilyTable.newIntegerColumn("id", false);
foodFamilyTable.newIntegerColumn("main_image_erattachment_id", true);
foodFamilyTable.newTimestampColumn("mod_date", true);
foodFamilyTable.newStringColumn("name", 255, false);
foodFamilyTable.newIntegerColumn("thumbnail_erattachment_id", true);
foodFamilyTable.create();
foodFamilyTable.setPrimaryKey("id");
ERXMigrationTable foodItemTable = database.newTableNamed("food_item");
foodItemTable.newTimestampColumn("add_date", true);
foodItemTable.newStringColumn("availability_status", 50, true);
foodItemTable.newStringColumn("food_family", 100, true);
foodItemTable.newStringColumn("fruit_or_vegetable_type", 100, true);
foodItemTable.newIntegerColumn("id", false);
foodItemTable.newIntegerColumn("main_image_erattachment_id", true);
foodItemTable.newTimestampColumn("mod_date", true);
foodItemTable.newStringColumn("name", 100, false);
foodItemTable.newBigDecimalColumn("price", 38, 4, true);
foodItemTable.newStringColumn("price_status", 50, false);
foodItemTable.newStringColumn("quality_status", 50, false);
foodItemTable.newBooleanColumn("seasonal_second_half_sep", true);
foodItemTable.newStringColumn("sku", 50, true);
foodItemTable.newIntegerColumn("thumbnail_erattachment_id", true);
foodItemTable.create();
foodItemTable.setPrimaryKey("id");
ERXMigrationTable newsItemTable = database.newTableNamed("news_item");
newsItemTable.newTimestampColumn("add_date", true);
newsItemTable.newDateColumn("entryDate", false);
newsItemTable.newIntegerColumn("food_family_id", false);
newsItemTable.newIntegerColumn("food_item_id", true);
newsItemTable.newIntegerColumn("id", false);
newsItemTable.newTimestampColumn("mod_date", true);
newsItemTable.newStringColumn("name", 255, false);
newsItemTable.create();
newsItemTable.setPrimaryKey("id");
foodFamilyTable.addForeignKey("main_image_erattachment_id", "ERAttachment", "id");
foodFamilyTable.addForeignKey("thumbnail_erattachment_id", "ERAttachment", "id");
foodItemTable.addForeignKey("main_image_erattachment_id", "ERAttachment", "id");
foodItemTable.addForeignKey("thumbnail_erattachment_id", "ERAttachment", "id");
newsItemTable.addForeignKey("food_family_id", "food_family", "id");
newsItemTable.addForeignKey("food_item_id", "food_item", "id");
}
}