From 3e21884b38b6ed9301f14f6f78c25a73f0caf001 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Fri, 30 Aug 2019 14:26:28 +0200 Subject: [PATCH] add deleted_at on article and constitution --- .../kotlin/fr/dcproject/entity/Article.kt | 3 ++- .../fr/dcproject/entity/Constitution.kt | 3 ++- .../sql/migrations/0000-init_schema.up.sql | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/fr/dcproject/entity/Article.kt b/src/main/kotlin/fr/dcproject/entity/Article.kt index d9ccb39..37cee04 100644 --- a/src/main/kotlin/fr/dcproject/entity/Article.kt +++ b/src/main/kotlin/fr/dcproject/entity/Article.kt @@ -15,4 +15,5 @@ class Article( UuidEntity(id), EntityVersioning by UuidEntityVersioning(), EntityCreatedAt by EntityCreatedAtImp(), - EntityCreatedBy by EntityCreatedByImp(createdBy) \ No newline at end of file + EntityCreatedBy by EntityCreatedByImp(createdBy), + EntityDeletedAt by EntityDeletedAtImp() \ No newline at end of file diff --git a/src/main/kotlin/fr/dcproject/entity/Constitution.kt b/src/main/kotlin/fr/dcproject/entity/Constitution.kt index 06e4a85..935c037 100644 --- a/src/main/kotlin/fr/dcproject/entity/Constitution.kt +++ b/src/main/kotlin/fr/dcproject/entity/Constitution.kt @@ -12,7 +12,8 @@ class Constitution( ): UuidEntity(id), EntityVersioning by UuidEntityVersioning(), EntityCreatedAt by EntityCreatedAtImp(), - EntityCreatedBy by EntityCreatedByImp(createdBy) { + EntityCreatedBy by EntityCreatedByImp(createdBy), + EntityDeletedAt by EntityDeletedAtImp() { init{ titles.forEachIndexed { index, title -> diff --git a/src/main/resources/sql/migrations/0000-init_schema.up.sql b/src/main/resources/sql/migrations/0000-init_schema.up.sql index 962ef5a..35028c3 100644 --- a/src/main/resources/sql/migrations/0000-init_schema.up.sql +++ b/src/main/resources/sql/migrations/0000-init_schema.up.sql @@ -12,11 +12,11 @@ create table "user" create table citizen ( - id uuid default uuid_generate_v4() not null primary key, - created_at timestamptz default now() not null, - name jsonb not null check ( name ? 'first_name' and name ? 'last_name' ), - birthday date not null, - user_id uuid not null references "user" (id) unique, + id uuid default uuid_generate_v4() not null primary key, + created_at timestamptz default now() not null, + name jsonb not null check ( name ? 'first_name' and name ? 'last_name' ), + birthday date not null, + user_id uuid not null references "user" (id) unique, vote_anonymous boolean default true not null, follow_anonymous boolean default true not null ); @@ -29,7 +29,7 @@ create table workgroup created_by_id uuid not null references citizen (id), name varchar(128) not null, description text null, - anonymous boolean default false not null, + anonymous boolean default false not null, logo text null, owner_id uuid not null references citizen (id) ); @@ -100,10 +100,11 @@ create table article version_id uuid default uuid_generate_v4() not null, version_number int not null, title text not null check ( length(title) < 128 ), - anonymous boolean default false not null, + anonymous boolean default false not null, content text not null check ( content != '' ), description text null check ( description != '' ), tags varchar(32)[] default '{}' not null, + deleted_at timestamptz default null null, unique (version_id, version_number) ); @@ -121,7 +122,9 @@ create table constitution version_id uuid default uuid_generate_v4() not null, version_number int not null, title text not null check ( length(title) < 128 ), - anonymous boolean default false not null + anonymous boolean default false not null, + deleted_at timestamptz default null null, + unique (version_id, version_number) ); create trigger generate_version_number_trigger