stibbs
11/07/2021, 10:58 PMsql
CREATE TABLE jobs (
id uuid DEFAULT uuid_generate_v4 () primary key,
invoice_id uuid references public.invoices not null,
user_id uuid references auth.users not null,
application_url text,
business_name text not null,
content_description text not null,
content_how_to_apply text not null,
content_who text not null,
job_location text,
job_type text not null,
title text not null,
timezone text,
work_style text not null,
valid_until timestamp with time zone,
);
The confusing bit to me is that in this table you either populate job job_location
OR timezone
depending on the value in work_style
I have no idea if I'm on the right path, but so far I have:
sql
insert into public.jobs (
invoice_id,
user_id,
application_url,
business_name,
content_description,
content_how_to_apply,
content_who,
job_location,
job_type,
title,
timezone,
work_style,
valid_until
)
select
'manually created invoice_id',
'manually created user_id',
'https://www.google.com',
MD5(random()::text), -- business_name
MD5(random()::text), -- content_description
MD5(random()::text), -- content_how_to_apply
MD5(random()::text), -- content_who
-- how do i make some populate job_location?
'ft', -- job_type
MD5(random()::text), -- title
-- how do i make some populate timezone?
-- work_style needs to be 'remote' or 'flex'
now() + interval '5 day'
from generate_series(1, 100);
garyaustin
11/07/2021, 11:48 PMstibbs
11/07/2021, 11:59 PMwork_style
. Something like
sql
select (array['remote', 'flex'])[floor(random() * 2 + 1)];
garyaustin
11/08/2021, 12:03 AMstibbs
11/08/2021, 12:04 AMif
or something to do that?stibbs
11/08/2021, 12:04 AMtimezone
is populated when work_style
= remote
stibbs
11/08/2021, 12:04 AMjob_location
is populated when work_style
= flex
garyaustin
11/08/2021, 12:04 AMstibbs
11/08/2021, 12:05 AMstibbs
11/08/2021, 12:05 AMgaryaustin
11/08/2021, 12:06 AMstibbs
11/08/2021, 12:06 AMstibbs
11/08/2021, 12:08 AMsql
insert into public.jobs (
invoice_id,
user_id,
application_url,
business_name,
content_description,
content_how_to_apply,
content_who,
job_location,
job_type,
title,
timezone,
work_style,
valid_until
)
select
'manually created invoice_id',
'manually created user_id',
'https://www.google.com',
substr(md5(random()::text), 0, 15), -- business_name
MD5(random()::text), -- content_description
MD5(random()::text), -- content_how_to_apply
MD5(random()::text), -- content_who
-- how do i make some populate job_location?
'ft', -- job_type
upper(substr(md5(random()::text), 0, 25)), -- title
-- how do i make some populate timezone?
(array['remote', 'flex'])[floor(random() * 2 + 1)],
now() + interval '5 day'
from generate_series(1, 100);
stibbs
11/08/2021, 12:11 AMws
only exists after query execution?
sql
select
substr(md5(random()::text), 0, 25) as title,
(array['remote', 'flex'])[floor(random() * 2 + 1)] as ws,
case when ws = 'remote' then 'aest'
else null
end
from generate_series(1, 10);
column "ws" does not exist
garyaustin
11/08/2021, 12:18 AMstibbs
11/08/2021, 12:19 AMinsert into ... values
?garyaustin
11/08/2021, 12:21 AMstibbs
11/08/2021, 12:21 AMgaryaustin
11/08/2021, 12:23 AM