restructured code
This commit is contained in:
275
account/sql/account.dbm
Normal file
275
account/sql/account.dbm
Normal file
@ -0,0 +1,275 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
CAUTION: Do not modify this file unless you know what you are doing.
|
||||
Unexpected results may occur if the code is changed deliberately.
|
||||
-->
|
||||
<dbmodel pgmodeler-ver="0.9.1" author="Joern Muehlencord" last-position="773,0" last-zoom="0.85"
|
||||
default-schema="public" default-owner="postgres">
|
||||
<database name="account_test" encoding="UTF8" lc-collate="German_Germany.1252" lc-ctype="German_Germany.1252" is-template="false" allow-conns="true" sql-disabled="true">
|
||||
</database>
|
||||
|
||||
<schema name="public" fill-color="#e1e1e1" sql-disabled="true">
|
||||
</schema>
|
||||
|
||||
<table name="config">
|
||||
<schema name="public"/>
|
||||
<position x="1912" y="120.235"/>
|
||||
<column name="config_key" not-null="true">
|
||||
<type name="varchar" length="100"/>
|
||||
</column>
|
||||
<column name="config_key_group">
|
||||
<type name="varchar" length="200"/>
|
||||
</column>
|
||||
<column name="config_key_account">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<column name="config_value">
|
||||
<type name="varchar" length="200"/>
|
||||
</column>
|
||||
<constraint name="config_pk" type="pk-constr" table="public.config">
|
||||
<columns names="config_key" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
</table>
|
||||
|
||||
<table name="application_role">
|
||||
<schema name="public"/>
|
||||
<position x="186.257" y="310"/>
|
||||
<column name="id" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<column name="role_name" not-null="true">
|
||||
<type name="character varying" length="80"/>
|
||||
</column>
|
||||
<column name="role_description" not-null="true">
|
||||
<type name="character varying" length="200"/>
|
||||
</column>
|
||||
<constraint name="pk_application_role_pk" type="pk-constr" table="public.application_role">
|
||||
<columns names="id" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
</table>
|
||||
|
||||
<table name="account">
|
||||
<schema name="public"/>
|
||||
<position x="1323.59" y="185.294"/>
|
||||
<column name="id" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<column name="username" not-null="true">
|
||||
<type name="character varying" length="32"/>
|
||||
</column>
|
||||
<column name="emailaddress" not-null="true">
|
||||
<type name="character varying" length="200"/>
|
||||
</column>
|
||||
<column name="firstname" not-null="true">
|
||||
<type name="character varying" length="100"/>
|
||||
</column>
|
||||
<column name="lastname" not-null="true">
|
||||
<type name="character varying" length="100"/>
|
||||
</column>
|
||||
<column name="account_password" not-null="true">
|
||||
<type name="character" length="200"/>
|
||||
</column>
|
||||
<column name="last_login">
|
||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
||||
</column>
|
||||
<column name="last_failed_login">
|
||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
||||
</column>
|
||||
<column name="failure_count" not-null="true" default-value="0">
|
||||
<type name="integer" length="0"/>
|
||||
</column>
|
||||
<column name="status" not-null="true" default-value="'NEW'">
|
||||
<type name="character varying" length="10"/>
|
||||
</column>
|
||||
<column name="password_reset_ongoing" not-null="true" default-value="false">
|
||||
<type name="boolean" length="0"/>
|
||||
</column>
|
||||
<column name="password_reset_valid_to">
|
||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
||||
</column>
|
||||
<column name="password_reset_hash">
|
||||
<type name="character" length="200"/>
|
||||
</column>
|
||||
<column name="created_on" not-null="true" default-value="timezone('utc'::text, now())">
|
||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
||||
</column>
|
||||
<column name="created_by" not-null="true">
|
||||
<type name="character varying" length="32"/>
|
||||
</column>
|
||||
<column name="last_updated_on" not-null="true" default-value="timezone('utc'::text, now())">
|
||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
||||
</column>
|
||||
<column name="last_updated_by" not-null="true">
|
||||
<type name="character varying" length="32"/>
|
||||
</column>
|
||||
<constraint name="pk_account" type="pk-constr" table="public.account">
|
||||
<columns names="id" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
<constraint name="uidx_username" type="uq-constr" table="public.account">
|
||||
<columns names="username" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
</table>
|
||||
|
||||
<table name="account_history">
|
||||
<schema name="public"/>
|
||||
<position x="725.984" y="294.706"/>
|
||||
<column name="id" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<column name="account_id" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<column name="message">
|
||||
<type name="character varying" length="200"/>
|
||||
</column>
|
||||
<column name="failure_count" not-null="true" default-value="0">
|
||||
<type name="integer" length="0"/>
|
||||
</column>
|
||||
<column name="status" not-null="true">
|
||||
<type name="character varying" length="20"/>
|
||||
</column>
|
||||
<column name="last_updated_on" not-null="true" default-value="timezone('utc'::text, now())">
|
||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
||||
</column>
|
||||
<column name="last_updated_by" not-null="true">
|
||||
<type name="character varying" length="32"/>
|
||||
</column>
|
||||
<constraint name="pk_account_history" type="pk-constr" table="public.account_history">
|
||||
<columns names="id" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
</table>
|
||||
|
||||
<table name="account_role">
|
||||
<schema name="public"/>
|
||||
<position x="738.806" y="90"/>
|
||||
<column name="account" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<column name="account_role" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<constraint name="pk_account_role" type="pk-constr" table="public.account_role">
|
||||
<columns names="account,account_role" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
</table>
|
||||
|
||||
<table name="application_permission">
|
||||
<schema name="public"/>
|
||||
<position x="1571.12" y="573.662"/>
|
||||
<column name="id" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<column name="permission_name" not-null="true">
|
||||
<type name="character varying" length="80"/>
|
||||
</column>
|
||||
<column name="permission_description" not-null="true">
|
||||
<type name="character varying" length="200"/>
|
||||
</column>
|
||||
<constraint name="pk_application_permission" type="pk-constr" table="public.application_permission">
|
||||
<columns names="id" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
<constraint name="uidx_application_permission_name" type="uq-constr" table="public.application_permission">
|
||||
<columns names="permission_name" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
</table>
|
||||
|
||||
<table name="role_permission">
|
||||
<schema name="public"/>
|
||||
<position x="617.922" y="582.191"/>
|
||||
<column name="application_role" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<column name="role_permission" not-null="true">
|
||||
<type name="uuid" length="0"/>
|
||||
</column>
|
||||
<constraint name="pk_role_permission_role_permission_name" type="pk-constr" table="public.role_permission">
|
||||
<columns names="application_role,role_permission" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
</table>
|
||||
|
||||
<table name="mail_template">
|
||||
<schema name="public"/>
|
||||
<position x="684.593" y="789.132"/>
|
||||
<column name="template_name" not-null="true">
|
||||
<type name="character varying" length="40"/>
|
||||
</column>
|
||||
<column name="template_value" not-null="true">
|
||||
<type name="text" length="0"/>
|
||||
</column>
|
||||
<constraint name="mail_template_pk" type="pk-constr" table="public.mail_template">
|
||||
<columns names="template_name" ref-type="src-columns"/>
|
||||
</constraint>
|
||||
</table>
|
||||
|
||||
<constraint name="config_key_account_fk" type="fk-constr" comparison-type="MATCH FULL"
|
||||
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.account" table="public.config">
|
||||
<columns names="config_key_account" ref-type="src-columns"/>
|
||||
<columns names="id" ref-type="dst-columns"/>
|
||||
</constraint>
|
||||
|
||||
<constraint name="fk_account_history_username_fk" type="fk-constr" comparison-type="MATCH SIMPLE"
|
||||
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.account" table="public.account_history">
|
||||
<columns names="account_id" ref-type="src-columns"/>
|
||||
<columns names="id" ref-type="dst-columns"/>
|
||||
</constraint>
|
||||
|
||||
<constraint name="fk_account_role_account" type="fk-constr" comparison-type="MATCH SIMPLE"
|
||||
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.account" table="public.account_role">
|
||||
<columns names="account" ref-type="src-columns"/>
|
||||
<columns names="id" ref-type="dst-columns"/>
|
||||
</constraint>
|
||||
|
||||
<constraint name="fk_account_role_role_name" type="fk-constr" comparison-type="MATCH SIMPLE"
|
||||
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.application_role" table="public.account_role">
|
||||
<columns names="account_role" ref-type="src-columns"/>
|
||||
<columns names="id" ref-type="dst-columns"/>
|
||||
</constraint>
|
||||
|
||||
<constraint name="fk_role_permission_application_role" type="fk-constr" comparison-type="MATCH SIMPLE"
|
||||
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.application_role" table="public.role_permission">
|
||||
<columns names="application_role" ref-type="src-columns"/>
|
||||
<columns names="id" ref-type="dst-columns"/>
|
||||
</constraint>
|
||||
|
||||
<constraint name="fk_role_permission_role_permission" type="fk-constr" comparison-type="MATCH SIMPLE"
|
||||
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.application_permission" table="public.role_permission">
|
||||
<columns names="role_permission" ref-type="src-columns"/>
|
||||
<columns names="id" ref-type="dst-columns"/>
|
||||
</constraint>
|
||||
|
||||
<relationship name="rel_account_history_account" type="relfk"
|
||||
custom-color="#83af1f"
|
||||
src-table="public.account_history"
|
||||
dst-table="public.account" reference-fk="fk_account_history_username_fk"
|
||||
src-required="false" dst-required="false"/>
|
||||
|
||||
<relationship name="rel_account_role_account" type="relfk"
|
||||
custom-color="#5aa578"
|
||||
src-table="public.account_role"
|
||||
dst-table="public.account" reference-fk="fk_account_role_account"
|
||||
src-required="false" dst-required="false"/>
|
||||
|
||||
<relationship name="rel_account_role_application_role" type="relfk"
|
||||
custom-color="#4b3e56"
|
||||
src-table="public.account_role"
|
||||
dst-table="public.application_role" reference-fk="fk_account_role_role_name"
|
||||
src-required="false" dst-required="false"/>
|
||||
|
||||
<relationship name="rel_role_permission_application_role" type="relfk"
|
||||
custom-color="#9ac721"
|
||||
src-table="public.role_permission"
|
||||
dst-table="public.application_role" reference-fk="fk_role_permission_application_role"
|
||||
src-required="false" dst-required="false"/>
|
||||
|
||||
<relationship name="rel_role_permission_application_permission" type="relfk"
|
||||
custom-color="#249b49"
|
||||
src-table="public.role_permission"
|
||||
dst-table="public.application_permission" reference-fk="fk_role_permission_role_permission"
|
||||
src-required="false" dst-required="false"/>
|
||||
|
||||
<relationship name="rel_config_account" type="relfk"
|
||||
src-table="public.config"
|
||||
dst-table="public.account" reference-fk="config_key_account_fk"
|
||||
src-required="false" dst-required="false"/>
|
||||
|
||||
</dbmodel>
|
||||
167
account/sql/account.sql
Normal file
167
account/sql/account.sql
Normal file
@ -0,0 +1,167 @@
|
||||
-- Database generated with pgModeler (PostgreSQL Database Modeler).
|
||||
-- pgModeler version: 0.9.1
|
||||
-- PostgreSQL version: 10.0
|
||||
-- Project Site: pgmodeler.io
|
||||
-- Model Author: Joern Muehlencord
|
||||
|
||||
|
||||
-- Database creation must be done outside a multicommand file.
|
||||
-- These commands were put in this file only as a convenience.
|
||||
-- -- object: account_test | type: DATABASE --
|
||||
-- -- DROP DATABASE IF EXISTS account_test;
|
||||
-- CREATE DATABASE account_test
|
||||
-- ENCODING = 'UTF8'
|
||||
-- LC_COLLATE = 'German_Germany.1252'
|
||||
-- LC_CTYPE = 'German_Germany.1252';
|
||||
-- -- ddl-end --
|
||||
--
|
||||
|
||||
-- object: public.config | type: TABLE --
|
||||
-- DROP TABLE IF EXISTS public.config CASCADE;
|
||||
CREATE TABLE public.config(
|
||||
config_key varchar(100) NOT NULL,
|
||||
config_key_group varchar(200),
|
||||
config_key_account uuid,
|
||||
config_value varchar(200),
|
||||
CONSTRAINT config_pk PRIMARY KEY (config_key)
|
||||
|
||||
);
|
||||
-- ddl-end --
|
||||
|
||||
-- object: public.application_role | type: TABLE --
|
||||
-- DROP TABLE IF EXISTS public.application_role CASCADE;
|
||||
CREATE TABLE public.application_role(
|
||||
id uuid NOT NULL,
|
||||
role_name character varying(80) NOT NULL,
|
||||
role_description character varying(200) NOT NULL,
|
||||
CONSTRAINT pk_application_role_pk PRIMARY KEY (id)
|
||||
|
||||
);
|
||||
-- ddl-end --
|
||||
|
||||
-- object: public.account | type: TABLE --
|
||||
-- DROP TABLE IF EXISTS public.account CASCADE;
|
||||
CREATE TABLE public.account(
|
||||
id uuid NOT NULL,
|
||||
username character varying(32) NOT NULL,
|
||||
emailaddress character varying(200) NOT NULL,
|
||||
firstname character varying(100) NOT NULL,
|
||||
lastname character varying(100) NOT NULL,
|
||||
account_password character(200) NOT NULL,
|
||||
last_login timestamp with time zone,
|
||||
last_failed_login timestamp with time zone,
|
||||
failure_count integer NOT NULL DEFAULT 0,
|
||||
status character varying(10) NOT NULL DEFAULT 'NEW',
|
||||
password_reset_ongoing boolean NOT NULL DEFAULT false,
|
||||
password_reset_valid_to timestamp with time zone,
|
||||
password_reset_hash character(200),
|
||||
created_on timestamp with time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
created_by character varying(32) NOT NULL,
|
||||
last_updated_on timestamp with time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
last_updated_by character varying(32) NOT NULL,
|
||||
CONSTRAINT pk_account PRIMARY KEY (id),
|
||||
CONSTRAINT uidx_username UNIQUE (username)
|
||||
|
||||
);
|
||||
-- ddl-end --
|
||||
|
||||
-- object: public.account_history | type: TABLE --
|
||||
-- DROP TABLE IF EXISTS public.account_history CASCADE;
|
||||
CREATE TABLE public.account_history(
|
||||
id uuid NOT NULL,
|
||||
account_id uuid NOT NULL,
|
||||
message character varying(200),
|
||||
failure_count integer NOT NULL DEFAULT 0,
|
||||
status character varying(20) NOT NULL,
|
||||
last_updated_on timestamp with time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
last_updated_by character varying(32) NOT NULL,
|
||||
CONSTRAINT pk_account_history PRIMARY KEY (id)
|
||||
|
||||
);
|
||||
-- ddl-end --
|
||||
|
||||
-- object: public.account_role | type: TABLE --
|
||||
-- DROP TABLE IF EXISTS public.account_role CASCADE;
|
||||
CREATE TABLE public.account_role(
|
||||
account uuid NOT NULL,
|
||||
account_role uuid NOT NULL,
|
||||
CONSTRAINT pk_account_role PRIMARY KEY (account,account_role)
|
||||
|
||||
);
|
||||
-- ddl-end --
|
||||
|
||||
-- object: public.application_permission | type: TABLE --
|
||||
-- DROP TABLE IF EXISTS public.application_permission CASCADE;
|
||||
CREATE TABLE public.application_permission(
|
||||
id uuid NOT NULL,
|
||||
permission_name character varying(80) NOT NULL,
|
||||
permission_description character varying(200) NOT NULL,
|
||||
CONSTRAINT pk_application_permission PRIMARY KEY (id),
|
||||
CONSTRAINT uidx_application_permission_name UNIQUE (permission_name)
|
||||
|
||||
);
|
||||
-- ddl-end --
|
||||
|
||||
-- object: public.role_permission | type: TABLE --
|
||||
-- DROP TABLE IF EXISTS public.role_permission CASCADE;
|
||||
CREATE TABLE public.role_permission(
|
||||
application_role uuid NOT NULL,
|
||||
role_permission uuid NOT NULL,
|
||||
CONSTRAINT pk_role_permission_role_permission_name PRIMARY KEY (application_role,role_permission)
|
||||
|
||||
);
|
||||
-- ddl-end --
|
||||
|
||||
-- object: public.mail_template | type: TABLE --
|
||||
-- DROP TABLE IF EXISTS public.mail_template CASCADE;
|
||||
CREATE TABLE public.mail_template(
|
||||
template_name character varying(40) NOT NULL,
|
||||
template_value text NOT NULL,
|
||||
CONSTRAINT mail_template_pk PRIMARY KEY (template_name)
|
||||
|
||||
);
|
||||
-- ddl-end --
|
||||
|
||||
-- object: config_key_account_fk | type: CONSTRAINT --
|
||||
-- ALTER TABLE public.config DROP CONSTRAINT IF EXISTS config_key_account_fk CASCADE;
|
||||
ALTER TABLE public.config ADD CONSTRAINT config_key_account_fk FOREIGN KEY (config_key_account)
|
||||
REFERENCES public.account (id) MATCH FULL
|
||||
ON DELETE NO ACTION ON UPDATE NO ACTION;
|
||||
-- ddl-end --
|
||||
|
||||
-- object: fk_account_history_username_fk | type: CONSTRAINT --
|
||||
-- ALTER TABLE public.account_history DROP CONSTRAINT IF EXISTS fk_account_history_username_fk CASCADE;
|
||||
ALTER TABLE public.account_history ADD CONSTRAINT fk_account_history_username_fk FOREIGN KEY (account_id)
|
||||
REFERENCES public.account (id) MATCH SIMPLE
|
||||
ON DELETE NO ACTION ON UPDATE NO ACTION;
|
||||
-- ddl-end --
|
||||
|
||||
-- object: fk_account_role_account | type: CONSTRAINT --
|
||||
-- ALTER TABLE public.account_role DROP CONSTRAINT IF EXISTS fk_account_role_account CASCADE;
|
||||
ALTER TABLE public.account_role ADD CONSTRAINT fk_account_role_account FOREIGN KEY (account)
|
||||
REFERENCES public.account (id) MATCH SIMPLE
|
||||
ON DELETE NO ACTION ON UPDATE NO ACTION;
|
||||
-- ddl-end --
|
||||
|
||||
-- object: fk_account_role_role_name | type: CONSTRAINT --
|
||||
-- ALTER TABLE public.account_role DROP CONSTRAINT IF EXISTS fk_account_role_role_name CASCADE;
|
||||
ALTER TABLE public.account_role ADD CONSTRAINT fk_account_role_role_name FOREIGN KEY (account_role)
|
||||
REFERENCES public.application_role (id) MATCH SIMPLE
|
||||
ON DELETE NO ACTION ON UPDATE NO ACTION;
|
||||
-- ddl-end --
|
||||
|
||||
-- object: fk_role_permission_application_role | type: CONSTRAINT --
|
||||
-- ALTER TABLE public.role_permission DROP CONSTRAINT IF EXISTS fk_role_permission_application_role CASCADE;
|
||||
ALTER TABLE public.role_permission ADD CONSTRAINT fk_role_permission_application_role FOREIGN KEY (application_role)
|
||||
REFERENCES public.application_role (id) MATCH SIMPLE
|
||||
ON DELETE NO ACTION ON UPDATE NO ACTION;
|
||||
-- ddl-end --
|
||||
|
||||
-- object: fk_role_permission_role_permission | type: CONSTRAINT --
|
||||
-- ALTER TABLE public.role_permission DROP CONSTRAINT IF EXISTS fk_role_permission_role_permission CASCADE;
|
||||
ALTER TABLE public.role_permission ADD CONSTRAINT fk_role_permission_role_permission FOREIGN KEY (role_permission)
|
||||
REFERENCES public.application_permission (id) MATCH SIMPLE
|
||||
ON DELETE NO ACTION ON UPDATE NO ACTION;
|
||||
-- ddl-end --
|
||||
|
||||
|
||||
11
account/sql/account_prefill.sql
Normal file
11
account/sql/account_prefill.sql
Normal file
@ -0,0 +1,11 @@
|
||||
-- config
|
||||
INSERT INTO config (config_key, config_value) VALUES ('account.maxFailedLogins', '5');
|
||||
|
||||
-- application configuration
|
||||
INSERT INTO application_permission (id, permission_name, permission_description) values ('dfd0f8f1-4a51-4fdc-9a1c-a942bee9b649', 'test:view', 'Display test view');
|
||||
INSERT INTO application_role (id, role_name, role_description) values ('5cd0aca0-5466-483d-8f3e-c369f8061131','Admin', 'Admin role');
|
||||
INSERT INTO application_role (id, role_name, role_description) values ('da30060e-fd23-4016-a506-4e12e9322148', 'User', 'Standard user role');
|
||||
|
||||
-- account
|
||||
INSERT INTO account (id, username, emailaddress, firstname, lastname, account_password, created_by, last_updated_by) values('ab5c8337-6872-4aea-a9b9-78ea63706b8f','admin', 'joern@muehlencord.de', 'Joern', 'Muehlencord','$shiro1$SHA-256$500000$4bHPNH9k539UjdFLgm/HOA==$T/n8skgoGSOtNw/c9ScDlXCiGrx2cZF0Esrvf6WPq6g=', 'admin','admin'); --admin/secret
|
||||
INSERT INTO account_role (account, account_role) values ('ab5c8337-6872-4aea-a9b9-78ea63706b8f', '5cd0aca0-5466-483d-8f3e-c369f8061131');
|
||||
9
account/sql/createDatabaseFileFromDBM.bat
Normal file
9
account/sql/createDatabaseFileFromDBM.bat
Normal file
@ -0,0 +1,9 @@
|
||||
@ECHO OFF
|
||||
set BASEDIR=%~dp0%
|
||||
set PGMODELER_DIR=c:\app\pgmodeler
|
||||
|
||||
setlocal
|
||||
cd %PGMODELER_DIR%
|
||||
pgmodeler-cli -if %BASEDIR%/account.dbm -ef -do -of %BASEDIR%/account.sql
|
||||
|
||||
pause
|
||||
Reference in New Issue
Block a user