Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (89 sloc) 6.63 KB
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<!-- Copyright 2019 Steinar Bang -->
<!-- -->
<!-- Licensed under the Apache License, Version 2.0 (the "License"); -->
<!-- you may not use this file except in compliance with the License. -->
<!-- You may obtain a copy of the License at -->
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- Unless required by applicable law or agreed to in writing, -->
<!-- software distributed under the License is distributed on an "AS IS" BASIS, -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<!-- See the License for the specific language governing permissions and limitations -->
<!-- under the License. -->
<!-- Executed after authservice liquibase has been inserted -->
<changeSet author="sb" id="update-authservice-users-from-ukelonn-users">
<sql>
insert into users (username, password, password_salt, email, firstname, lastname)
select ukelonn_users.username, ukelonn_users.password, ukelonn_users.salt, ukelonn_users.email, ukelonn_users.first_name, ukelonn_users.last_name from ukelonn_users
where ukelonn_users.username not in (select username from users)
order by ukelonn_users.user_id
</sql>
</changeSet>
<changeSet author="sb" id="insert-ukelonn-shiro-roles">
<sql>
insert into roles (role_name, description) values ('ukelonnuser', 'A user in the ukelonn application');
insert into roles (role_name, description) values ('ukelonnadmin', 'An administrator of the ukelonn application');
</sql>
</changeSet>
<changeSet author="sb" id="insert-ukelonnuser-role-for-all-users">
<sql>
insert into user_roles (role_name,username) select 'ukelonnuser', users.username from users order by users.user_id
</sql>
</changeSet>
<changeSet author="sb" id="insert-ukelonnadmin-role-for-administrators">
<sql>
insert into user_roles (role_name,username) select 'ukelonnadmin', u.username from users u join administrators a on a.username=u.username order by u.user_id
</sql>
</changeSet>
<changeSet author="sb" id="drop-administrators-table">
<dropTable tableName="administrators" />
</changeSet>
<changeSet author="sb" id="drop-ukelonn-users-table">
<dropTable tableName="ukelonn_users" />
</changeSet>
<changeSet author="sb" id="sum-over-year-view-derby">
<preConditions onFail="CONTINUE" >
<and>
<not>
<viewExists viewName="sum_over_year_view" />
</not>
<dbms type="derby" />
</and>
</preConditions>
<createView viewName="sum_over_year_view" fullDefinition="false" >select sum(t.transaction_amount) as aggregate_amount, YEAR(t.transaction_time) as aggregate_year, a.username as username from transactions t join transaction_types tt on tt.transaction_type_id=t.transaction_type_id join accounts a on a.account_id=t.account_id where tt.transaction_is_work group by YEAR(t.transaction_time), a.username order by YEAR(t.transaction_time)</createView>
</changeSet>
<changeSet author="sb" id="sum-over-year-view-postgresql">
<preConditions onFail="CONTINUE" >
<and>
<not>
<viewExists viewName="sum_over_year_view" />
</not>
<dbms type="postgresql" />
</and>
</preConditions>
<createView viewName="sum_over_year_view" fullDefinition="false">select sum(t.transaction_amount) as aggregate_amount, extract(year from t.transaction_time) as aggregate_year, a.username as username from transactions t join transaction_types tt on tt.transaction_type_id=t.transaction_type_id join accounts a on a.account_id=t.account_id where tt.transaction_is_work group by extract(year from t.transaction_time), a.username order by extract(year from t.transaction_time)</createView>
</changeSet>
<changeSet author="sb" id="sum-over-year-and-month-view-derby">
<preConditions onFail="CONTINUE" >
<and>
<not>
<viewExists viewName="sum_over_year_and_month_view" />
</not>
<dbms type="derby" />
</and>
</preConditions>
<createView viewName="sum_over_year_and_month_view" fullDefinition="false" >select sum(t.transaction_amount) as aggregate_amount, YEAR(t.transaction_time) as aggregate_year, MONTH(t.transaction_time) as aggregate_month, a.username as username from transactions t join transaction_types tt on tt.transaction_type_id=t.transaction_type_id join accounts a on a.account_id=t.account_id where tt.transaction_is_work group by YEAR(t.transaction_time), MONTH(t.transaction_time), a.username order by YEAR(t.transaction_time), MONTH(t.transaction_time)</createView>
</changeSet>
<changeSet author="sb" id="sum-over-year-and-month-view-postgresql">
<preConditions onFail="CONTINUE" >
<and>
<not>
<viewExists viewName="sum_over_year_and_month_view" />
</not>
<dbms type="postgresql" />
</and>
</preConditions>
<createView viewName="sum_over_year_and_month_view" fullDefinition="false">select sum(t.transaction_amount) as aggregate_amount, extract(year from t.transaction_time) as aggregate_year, extract(month from t.transaction_time) as aggregate_month, a.username as username from transactions t join transaction_types tt on tt.transaction_type_id=t.transaction_type_id join accounts a on a.account_id=t.account_id where tt.transaction_is_work group by extract(year from t.transaction_time), extract(month from t.transaction_time), a.username order by extract(year from t.transaction_time), extract(month from t.transaction_time)</createView>
</changeSet>
</databaseChangeLog>
You can’t perform that action at this time.