<?xml version="1.0" encoding="UTF-8"?>
<changeSet>
  <createTable tableName="RELEASE">
    <column name="USER_NAME" type="varchar(100)" nullable="false"/>
    <column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
    <column name="TAG" type="varchar(100)" nullable="false"/>
    <column name="NAME" type="varchar(100)" nullable="false"/>
    <column name="AUTHOR" type="varchar(100)" nullable="false"/>
    <column name="CONTENT" type="text" nullable="true"/>
    <column name="REGISTERED_DATE" type="datetime" nullable="false"/>
    <column name="UPDATED_DATE" type="datetime" nullable="false"/>
  </createTable>

  <addPrimaryKey constraintName="IDX_RELEASE_PK" tableName="RELEASE" columnNames="USER_NAME, REPOSITORY_NAME, TAG"/>
  <addForeignKeyConstraint constraintName="IDX_RELEASE_FK0" baseTableName="RELEASE" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>

  <createTable tableName="RELEASE_ASSET">
    <column name="USER_NAME" type="varchar(100)" nullable="false"/>
    <column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
    <column name="TAG" type="varchar(100)" nullable="false"/>
    <column name="RELEASE_ASSET_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
    <column name="FILE_NAME" type="varchar(260)" nullable="false"/>
    <column name="LABEL" type="varchar(100)" nullable="true"/>
    <column name="SIZE" type="bigint" nullable="false"/>
    <column name="UPLOADER" type="varchar(100)" nullable="false"/>
    <column name="REGISTERED_DATE" type="datetime" nullable="false"/>
    <column name="UPDATED_DATE" type="datetime" nullable="false"/>
  </createTable>
  <addPrimaryKey constraintName="IDX_RELEASE_ASSET_PK" tableName="RELEASE_ASSET" columnNames="USER_NAME, REPOSITORY_NAME, TAG, FILE_NAME"/>
  <addForeignKeyConstraint constraintName="IDX_RELEASE_ASSET_FK1" baseTableName="RELEASE_ASSET" baseColumnNames="USER_NAME, REPOSITORY_NAME, TAG" referencedTableName="RELEASE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, TAG"/>

  <createTable tableName="ACCOUNT_FEDERATION">
    <column name="ISSUER" type="varchar(100)" nullable="false"/>
    <column name="SUBJECT" type="varchar(100)" nullable="false"/>
    <column name="USER_NAME" type="varchar(100)" nullable="false"/>
  </createTable>
  <addPrimaryKey constraintName="IDX_ACCOUNT_FEDERATION_PK" tableName="ACCOUNT_FEDERATION" columnNames="ISSUER, SUBJECT"/>
  <addForeignKeyConstraint constraintName="IDX_ACCOUNT_FEDERATION_FK0" baseTableName="ACCOUNT_FEDERATION" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
</changeSet>
