historicization of JHI_USER table
This commit is contained in:
parent
cbb5532394
commit
354cfbbebc
@ -56,7 +56,7 @@ Then start the application with the pgsql profile:
|
||||
gw bootRun -Ppgsql
|
||||
gw bootRun -Ppgsql -Psample-data # populated with sample data
|
||||
|
||||
To use a **remote Postgres database** on a hostsharing server,
|
||||
To use a **remote Postgres database** on a Hostsharing server,
|
||||
|
||||
autossh -M 0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" \
|
||||
-f -N -L 55432:127.0.0.1:5432 "xyz00@xyz.hostsharing.net"
|
||||
|
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
|
||||
|
||||
<!-- Table for historical user data. -->
|
||||
<changeSet id="20190526150000-1" author="mhierweck,mhoennig" dbms="postgresql">
|
||||
|
||||
<createTable tableName="jhi_user_history">
|
||||
|
||||
<!-- history-related columns -->
|
||||
|
||||
<column name="history_id" type="bigint" autoIncrement="true">
|
||||
<constraints primaryKey="true" unique="true" nullable="false"/>
|
||||
</column>
|
||||
|
||||
<column name="history_transaction" type="bigint">
|
||||
<constraints nullable="false" />
|
||||
</column>
|
||||
|
||||
<column name="history_tombstone" type="bool">
|
||||
<constraints nullable="false" />
|
||||
</column>
|
||||
|
||||
<!-- id-column like in base table, but no primary key nor unique -->
|
||||
|
||||
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
|
||||
<!-- all following columns like in base table, dropping unique constraints -->
|
||||
|
||||
<column name="login" type="varchar(50)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="password_hash" type="varchar(60)"/>
|
||||
<column name="first_name" type="varchar(50)"/>
|
||||
<column name="last_name" type="varchar(50)"/>
|
||||
<column name="email" type="varchar(191)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="image_url" type="varchar(256)"/>
|
||||
<column name="activated" type="boolean" valueBoolean="false">
|
||||
<constraints nullable="false" />
|
||||
</column>
|
||||
<column name="lang_key" type="varchar(6)"/>
|
||||
<column name="activation_key" type="varchar(20)"/>
|
||||
<column name="reset_key" type="varchar(20)"/>
|
||||
<column name="created_by" type="varchar(50)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="created_date" type="timestamp"/>
|
||||
<column name="reset_date" type="timestamp">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="last_modified_by" type="varchar(50)"/>
|
||||
<column name="last_modified_date" type="timestamp"/>
|
||||
</createTable>
|
||||
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="20190526150000-2" author="mhierweck,mhoennig" dbms="postgresql">
|
||||
|
||||
<addForeignKeyConstraint baseColumnNames="history_transaction"
|
||||
baseTableName="jhi_user_history"
|
||||
constraintName="fk_jhi_user_history_transaction"
|
||||
referencedColumnNames="history_transaction"
|
||||
referencedTableName="history"/>
|
||||
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="20190526150000-3" author="mhierweck,mhoennig" dbms="postgresql">
|
||||
<createProcedure>
|
||||
CREATE TRIGGER jhi_user_historicize
|
||||
AFTER INSERT OR DELETE OR UPDATE ON jhi_user
|
||||
FOR EACH ROW EXECUTE PROCEDURE historicize();
|
||||
</createProcedure>
|
||||
<rollback>
|
||||
DROP TRIGGER jhi_user_historicize
|
||||
</rollback>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="20190526150000-4" author="mhierweck,mhoennig" dbms="postgresql">
|
||||
<createView viewName="jhi_user_history_view" replaceIfExists="true">
|
||||
SELECT *
|
||||
FROM jhi_user_history
|
||||
WHERE history_id IN (
|
||||
SELECT max(history_id) AS history_id
|
||||
FROM jhi_user_history
|
||||
WHERE history_transaction <= current_setting('history.transaction')::bigint
|
||||
GROUP BY login) -- must have a unique constraint
|
||||
</createView>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
@ -7,7 +7,11 @@
|
||||
<!-- initial JHipster tables (user etc.) -->
|
||||
<include file="config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
|
||||
|
||||
<!-- sample data. comes after historicization triggers, historicization applies -->
|
||||
<!-- historicization for initial JHipster tables -->
|
||||
<include file="config/liquibase/historicization/historicization.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/historicization/historicization_User.xml" relativeToChangelogFile="false"/>
|
||||
|
||||
<!-- sample data. comes after historicization triggers, thus historicization applies -->
|
||||
<include file="config/liquibase/sample-data/users.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/sample-data/users_authorities.xml" relativeToChangelogFile="false"/>
|
||||
|
||||
@ -32,8 +36,7 @@
|
||||
<include file="config/liquibase/changelog/constraints_UserRoleAssignment.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/changelog/constraints_Membership.xml" relativeToChangelogFile="false"/>
|
||||
|
||||
<!-- historicization -->
|
||||
<include file="config/liquibase/historicization/historicization.xml" relativeToChangelogFile="false"/>
|
||||
<!-- historicization for hsadmin specific tables -->
|
||||
<include file="config/liquibase/historicization/historicization_UserRoleAssignment.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/historicization/historicization_Customer.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/historicization/historicization_Membership.xml" relativeToChangelogFile="false"/>
|
||||
|
Loading…
Reference in New Issue
Block a user