add email to citizen table
This commit is contained in:
@@ -2,7 +2,7 @@ do
|
|||||||
$$
|
$$
|
||||||
begin
|
begin
|
||||||
delete from citizen;
|
delete from citizen;
|
||||||
insert into citizen (id, name, birthday, user_id, vote_anonymous, follow_anonymous)
|
insert into citizen (id, name, birthday, user_id, vote_anonymous, follow_anonymous, email)
|
||||||
select
|
select
|
||||||
uuid_in(md5('citizen'||row_number() over ()::text)::cstring),
|
uuid_in(md5('citizen'||row_number() over ()::text)::cstring),
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
@@ -13,7 +13,8 @@ begin
|
|||||||
now() - interval '25 years',
|
now() - interval '25 years',
|
||||||
u.id,
|
u.id,
|
||||||
row_number() over () % 3 = 0,
|
row_number() over () % 3 = 0,
|
||||||
row_number() over () % 5 = 1
|
row_number() over () % 5 = 1,
|
||||||
|
u.username || '@domain'|| (row_number() over () % 5 = 1) || '.com'
|
||||||
from "user" u;
|
from "user" u;
|
||||||
|
|
||||||
raise notice 'citizen fixtures done';
|
raise notice 'citizen fixtures done';
|
||||||
|
|||||||
@@ -7,21 +7,23 @@ declare
|
|||||||
begin
|
begin
|
||||||
select insert_user(resource->'user') into inserted_user;
|
select insert_user(resource->'user') into inserted_user;
|
||||||
|
|
||||||
insert into citizen (id, name, birthday, user_id, vote_anonymous, follow_anonymous)
|
insert into citizen (id, name, birthday, user_id, vote_anonymous, follow_anonymous, email)
|
||||||
select
|
select
|
||||||
coalesce(id, uuid_generate_v4()),
|
coalesce(id, uuid_generate_v4()),
|
||||||
name,
|
name,
|
||||||
birthday,
|
birthday,
|
||||||
(inserted_user->>'id')::uuid,
|
(inserted_user->>'id')::uuid,
|
||||||
coalesce(vote_anonymous, true),
|
coalesce(vote_anonymous, true),
|
||||||
coalesce(follow_anonymous, true)
|
coalesce(follow_anonymous, true),
|
||||||
|
email
|
||||||
from json_populate_record(null::citizen, resource)
|
from json_populate_record(null::citizen, resource)
|
||||||
on conflict (id) do update set
|
on conflict (id) do update set
|
||||||
name = excluded.name,
|
name = excluded.name,
|
||||||
birthday = excluded.birthday,
|
birthday = excluded.birthday,
|
||||||
user_id = excluded.user_id,
|
user_id = excluded.user_id,
|
||||||
vote_anonymous = excluded.vote_anonymous,
|
vote_anonymous = excluded.vote_anonymous,
|
||||||
follow_anonymous = excluded.follow_anonymous
|
follow_anonymous = excluded.follow_anonymous,
|
||||||
|
email = excluded.email
|
||||||
returning id into new_id;
|
returning id into new_id;
|
||||||
|
|
||||||
select find_citizen_by_id_with_user(new_id) into resource;
|
select find_citizen_by_id_with_user(new_id) into resource;
|
||||||
|
|||||||
@@ -4,21 +4,23 @@ $$
|
|||||||
declare
|
declare
|
||||||
new_id uuid;
|
new_id uuid;
|
||||||
begin
|
begin
|
||||||
insert into citizen (id, name, birthday, user_id, vote_anonymous, follow_anonymous)
|
insert into citizen (id, name, birthday, user_id, vote_anonymous, follow_anonymous, email)
|
||||||
select
|
select
|
||||||
coalesce(id, uuid_generate_v4()),
|
coalesce(id, uuid_generate_v4()),
|
||||||
name,
|
name,
|
||||||
birthday,
|
birthday,
|
||||||
(resource#>>'{user, id}')::uuid,
|
(resource#>>'{user, id}')::uuid,
|
||||||
coalesce(vote_anonymous, true),
|
coalesce(vote_anonymous, true),
|
||||||
coalesce(follow_anonymous, true)
|
coalesce(follow_anonymous, true),
|
||||||
|
email
|
||||||
from json_populate_record(null::citizen, resource)
|
from json_populate_record(null::citizen, resource)
|
||||||
on conflict (id) do update set
|
on conflict (id) do update set
|
||||||
name = excluded.name,
|
name = excluded.name,
|
||||||
birthday = excluded.birthday,
|
birthday = excluded.birthday,
|
||||||
user_id = excluded.user_id,
|
user_id = excluded.user_id,
|
||||||
vote_anonymous = excluded.vote_anonymous,
|
vote_anonymous = excluded.vote_anonymous,
|
||||||
follow_anonymous = excluded.follow_anonymous
|
follow_anonymous = excluded.follow_anonymous,
|
||||||
|
email = excluded.email
|
||||||
returning id into new_id;
|
returning id into new_id;
|
||||||
|
|
||||||
select find_citizen_by_id(new_id) into resource;
|
select find_citizen_by_id(new_id) into resource;
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ create table citizen
|
|||||||
birthday date not null,
|
birthday date not null,
|
||||||
user_id uuid not null references "user" (id) unique,
|
user_id uuid not null references "user" (id) unique,
|
||||||
vote_anonymous boolean default true not null,
|
vote_anonymous boolean default true not null,
|
||||||
follow_anonymous boolean default true not null
|
follow_anonymous boolean default true not null,
|
||||||
|
email text not null check ( email ~* '.+@.+\..+' )
|
||||||
);
|
);
|
||||||
|
|
||||||
create table workgroup
|
create table workgroup
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ declare
|
|||||||
created_user json := '{"username": "george", "plain_password": "azerty", "roles": ["ROLE_USER"]}';
|
created_user json := '{"username": "george", "plain_password": "azerty", "roles": ["ROLE_USER"]}';
|
||||||
_user_id uuid;
|
_user_id uuid;
|
||||||
_citizen_id uuid;
|
_citizen_id uuid;
|
||||||
created_citizen json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01"}';
|
created_citizen json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01", "email":"george.michel@gmail.com"}';
|
||||||
created_article json := '{"version_id":"933b6a1b-50c9-42b6-989f-c02a57814ef9", "title": "Love the world", "anonymous": false, "content": "bla bal bla", "tags": ["love", "test"], "draft":false}';
|
created_article json := '{"version_id":"933b6a1b-50c9-42b6-989f-c02a57814ef9", "title": "Love the world", "anonymous": false, "content": "bla bal bla", "tags": ["love", "test"], "draft":false}';
|
||||||
created_article_v2 json;
|
created_article_v2 json;
|
||||||
first_article_id uuid;
|
first_article_id uuid;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ declare
|
|||||||
wrong_citizen json;
|
wrong_citizen json;
|
||||||
created_user json := '{"username": "george", "plain_password": "azerty", "roles": ["ROLE_USER"]}';
|
created_user json := '{"username": "george", "plain_password": "azerty", "roles": ["ROLE_USER"]}';
|
||||||
_user_id uuid;
|
_user_id uuid;
|
||||||
created_citizen json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01"}';
|
created_citizen json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01", "email":"george.michel@gmail.com"}';
|
||||||
created_citizen_with_user json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01", "user":{"username": "george junior", "plain_password": "azerty", "roles": ["ROLE_USER"]}}';
|
created_citizen_with_user json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01", "email":"george.michel@gmail.com", "user":{"username": "george junior", "plain_password": "azerty", "roles": ["ROLE_USER"]}}';
|
||||||
selected_citizen json;
|
selected_citizen json;
|
||||||
begin
|
begin
|
||||||
-- insert user for context
|
-- insert user for context
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ declare
|
|||||||
"first_name": "George",
|
"first_name": "George",
|
||||||
"last_name": "MICHEL"
|
"last_name": "MICHEL"
|
||||||
},
|
},
|
||||||
"birthday": "2001-01-01"
|
"birthday": "2001-01-01",
|
||||||
|
"email":"george.michel@gmail.com"
|
||||||
}
|
}
|
||||||
$json$;
|
$json$;
|
||||||
created_article json := $json$
|
created_article json := $json$
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ declare
|
|||||||
"first_name": "George",
|
"first_name": "George",
|
||||||
"last_name": "MICHEL"
|
"last_name": "MICHEL"
|
||||||
},
|
},
|
||||||
"birthday": "2001-01-01"
|
"birthday": "2001-01-01",
|
||||||
|
"email":"george.michel@gmail.com"
|
||||||
}
|
}
|
||||||
$json$;
|
$json$;
|
||||||
created_article json := $json$
|
created_article json := $json$
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ declare
|
|||||||
"first_name": "George",
|
"first_name": "George",
|
||||||
"last_name": "MICHEL"
|
"last_name": "MICHEL"
|
||||||
},
|
},
|
||||||
"birthday": "2001-01-01"
|
"birthday": "2001-01-01",
|
||||||
|
"email":"george.michel@gmail.com"
|
||||||
}
|
}
|
||||||
$json$;
|
$json$;
|
||||||
created_citizen2 json := $json$
|
created_citizen2 json := $json$
|
||||||
@@ -20,7 +21,8 @@ declare
|
|||||||
"first_name": "John",
|
"first_name": "John",
|
||||||
"last_name": "Doe"
|
"last_name": "Doe"
|
||||||
},
|
},
|
||||||
"birthday": "2002-01-01"
|
"birthday": "2002-01-01",
|
||||||
|
"email":"george.michel@gmail.com"
|
||||||
}
|
}
|
||||||
$json$;
|
$json$;
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ declare
|
|||||||
"first_name": "George",
|
"first_name": "George",
|
||||||
"last_name": "MICHEL"
|
"last_name": "MICHEL"
|
||||||
},
|
},
|
||||||
"birthday": "2001-01-01"
|
"birthday": "2001-01-01",
|
||||||
|
"email":"george.michel@gmail.com"
|
||||||
}
|
}
|
||||||
$json$;
|
$json$;
|
||||||
created_citizen2 json := $json$
|
created_citizen2 json := $json$
|
||||||
@@ -20,7 +21,8 @@ declare
|
|||||||
"first_name": "George2",
|
"first_name": "George2",
|
||||||
"last_name": "MICHEL2"
|
"last_name": "MICHEL2"
|
||||||
},
|
},
|
||||||
"birthday": "2001-01-02"
|
"birthday": "2001-01-02",
|
||||||
|
"email":"george.michel@gmail.com"
|
||||||
}
|
}
|
||||||
$json$;
|
$json$;
|
||||||
created_article json := $json$
|
created_article json := $json$
|
||||||
|
|||||||
Reference in New Issue
Block a user