26 lines
837 B
SQL
26 lines
837 B
SQL
-- Add login table
|
|
create table if not exists people (
|
|
id uuid NOT NULL DEFAULT gen_random_uuid (),
|
|
created_at timestamp without time zone NOT NULL DEFAULT now(),
|
|
created_by uuid NOT NULL,
|
|
updated_at timestamp without time zone NOT NULL DEFAULT now(),
|
|
updated_by uuid NOT NULL,
|
|
email text NOT NULL,
|
|
name text NOT NULL,
|
|
family_name text NOT NULL,
|
|
given_name text NOT NULL
|
|
);
|
|
|
|
ALTER TABLE
|
|
people
|
|
ADD
|
|
CONSTRAINT people_pkey PRIMARY KEY (id);
|
|
|
|
ALTER TABLE if exists users
|
|
ADD COLUMN person_id uuid REFERENCES people (id) ON DELETE SET NULL;
|
|
|
|
-- Copy data
|
|
insert into people (created_by, updated_by, email, name, family_name, given_name)
|
|
select created_by, updated_by, email, name, family_name, given_name from users;
|
|
|
|
update users u set person_id = p.id from people p where p.email = u.email; |