Skip to content

Commit d874b32

Browse files
committed
Add CREATED_AT and CREATED_BY columns.
1 parent 743a303 commit d874b32

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/main/resources/liquibase/version/0.4/2016-09-28--add_creator_data_to_series_sales.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@
66
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
77

88
<changeSet id="add-creator-columns-to-series_sales_table" author="cssru" context="scheme">
9-
<comment>Adds created_at and created_by columns to series_sales table and fills them with default data</comment>
109

1110
<addColumn tableName="series_sales">
12-
<column name="created_at" type="DATETIME" defaultValueComputed="${NOW}">
13-
<constraints nullable="false" />
14-
</column>
11+
<column name="created_at" type="DATETIME" />
1512
<column name="created_by" type="INTEGER"
16-
defaultValueComputed="SELECT u.id FROM users u WHERE u.role = 'ADMIN'">
13+
defaultValueComputed="SELECT u.id FROM users u WHERE u.role = 'ADMIN' LIMIT 1">
1714
<constraints nullable="false"
1815
references="users(id)"
19-
foreignKeyName="fk_series_sales_created_by" />
16+
foreignKeyName="fk_series_sales_users_id" />
2017
</column>
2118
</addColumn>
2219

20+
<update tableName="series_sales">
21+
<column name="created_at" type="DATETIME" value="NOW()" />
22+
</update>
23+
24+
<addNotNullConstraint columnName="created_at" columnDataType="DATETIME" tableName="series_sales" />
25+
2326
</changeSet>
2427

2528
</databaseChangeLog>

0 commit comments

Comments
 (0)