<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
    <!--
    为了数据库的可移植性，建议采用这种方式，尽量减少引入sql文件
    -->
    <changeSet id="202403070002" author="liangbo.huang" >
        <comment>创建用户表</comment>
        <createTable remarks="用户表" tableName="test_create_table">
            <column autoIncrement="true" name="id" type="INT" remarks="主键">
                <constraints nullable="false" primaryKey="true" unique="true"/>
            </column>
            <column name="username" remarks="用户名" type="VARCHAR(32)">
                <constraints unique="true" nullable="false"/>
            </column>
            <column name="password" remarks="密码" type="VARCHAR(100)">
                <constraints unique="false" nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <changeSet id="202403070003" author="liangbo.huang">
        <comment>用户表添加邮箱字段</comment>
        <addColumn tableName="test_create_table">
            <column name="email" type="VARCHAR(32)" remarks="邮箱">
                <constraints nullable="true"/>
            </column>
        </addColumn>
    </changeSet>

    <changeSet id="202403070004" author="liangbo.huang">
        <comment>修改用户表邮箱字段名</comment>
        <renameColumn tableName="test_create_table" oldColumnName="email" newColumnName="newEmail" columnDataType="VARCHAR(50)"/>
    </changeSet>

    <changeSet id="202403070005" author="liangbo.huang">
        <comment>用户表插入记录</comment>
        <insert tableName="test_create_table">
            <column name="id" value="1"></column>
            <column name="username" value="zs"></column>
            <column name="password" value="123"></column>
            <column name="newEmail" value="zs@163.com"></column>
        </insert>
    </changeSet>

</databaseChangeLog>