-- HIVE-972: Support views
ALTER TABLE "TBLS" ADD "VIEW_ORIGINAL_TEXT" LONG VARCHAR DEFAULT NULL;
ALTER TABLE "TBLS" ADD "VIEW_EXPANDED_TEXT" LONG VARCHAR DEFAULT NULL;

-- HIVE-1068: CREATE VIEW followup: add a 'table type' enum
--            attribute in metastore
ALTER TABLE "TBLS" ADD COLUMN "TBL_TYPE" VARCHAR(128);

-- HIVE-675: Add database/schema support for Hive QL
ALTER TABLE "DBS" ALTER "DESC" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "DBS" ADD "DB_LOCATION_URI" VARCHAR(4000) NOT NULL DEFAULT '';

-- HIVE-1364: Increase the maximum length of various metastore fields,
--            and remove TYPE_NAME from COLUMNS primary key
ALTER TABLE "TBLS" ALTER "OWNER" SET DATA TYPE VARCHAR(767);
ALTER TABLE "COLUMNS" ALTER "TYPE_NAME" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "PARTITION_KEYS" ALTER "PKEY_COMMENT" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "SD_PARAMS" ALTER "PARAM_VALUE" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "SDS" ALTER "INPUT_FORMAT" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "SDS" ALTER "LOCATION" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "SDS" ALTER "OUTPUT_FORMAT" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "SERDE_PARAMS" ALTER "PARAM_VALUE" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "SERDES" ALTER "SLIB" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "TABLE_PARAMS" ALTER "PARAM_VALUE" SET DATA TYPE VARCHAR(4000);
ALTER TABLE "COLUMNS" DROP PRIMARY KEY;
ALTER TABLE "COLUMNS" ADD PRIMARY KEY ("SD_ID", "COLUMN_NAME");
ALTER TABLE "PARTITION_PARAMS" ALTER "PARAM_VALUE" SET DATA TYPE VARCHAR(4000);
