SETY
09/14/2021, 12:34 AMstibbs
09/14/2021, 1:43 AMnot null
would've made that work, but then you'd have existing data which does not meet your constraint requirement. Postgres helps you prevent that by giving the error. Once you have the error, you can reconsider whether the constraint is necessary, and if so, do one of the following:
1) add a default value to the column (which will populate for all existing rows); or
2) add the new column without the constraint, manually populate that column for your existing rows, and then re-add the constraintbokolesnik
09/14/2021, 8:52 AMstibbs
09/14/2021, 12:16 PMnow
is, like below.
My question: is there a built-in way of doing now
in PSQL?
ts
const now = new Date().getTime();
export const listPosts = async (): Promise<PostgrestResponse<PostTable>> => {
return supabase
.from<PostTable>('posts')
.select('*')
.gt('expires_at', now)
};
silentworks
09/14/2021, 12:31 PMTM
09/14/2021, 1:07 PMScott P
09/14/2021, 3:29 PMSubh
09/15/2021, 8:45 AMwith username as select 'user' || round(EXTRACT (EPOCH FROM now())::float*1000);
Is there a way to pass this as a variable?
create or replace function public.handle_new_user()
returns trigger as $$
with username as select 'user' || round(EXTRACT (EPOCH FROM now())::float*1000);
begin
insert into public.users (id, username, email)
values (new.id, username, new.email);
return new;
end;
$$ language plpgsql security definer;
Subh
09/15/2021, 8:50 AM(select 'user' || round(EXTRACT (EPOCH FROM now())::float*1000))
need to do thisLuddensEkko
09/15/2021, 11:56 AMLuddensEkko
09/15/2021, 11:58 AMsilentworks
09/15/2021, 12:00 PMLuddensEkko
09/15/2021, 12:03 PMsilentworks
09/15/2021, 12:04 PMLuddensEkko
09/15/2021, 12:27 PMjcald
09/17/2021, 4:22 PMjcald
09/17/2021, 5:01 PMsilentworks
09/17/2021, 5:14 PMsynchron
09/18/2021, 9:58 AMsynchron
09/18/2021, 9:59 AMsynchron
09/18/2021, 9:59 AMnkmnz
09/18/2021, 11:30 AMWITH CHECK
for insert, but USING
for update operations?
```
create policy "Users can insert their own profile."
on profiles for insert
with check ( auth.uid() = id );
create policy "Users can update own profile."
on profiles for update
using ( auth.uid() = id );
``jbergius
09/19/2021, 6:08 PMjcald
09/19/2021, 6:24 PMjbergius
09/19/2021, 6:40 PMSETY
09/20/2021, 1:19 PMScott P
09/20/2021, 5:27 PMjbergius
09/20/2021, 5:30 PMScott P
09/20/2021, 5:35 PMSELECT * FROM my_table WHERE metadata -> 'company' = '65'
The ->
essentially tells it to look inside the contents of the column (metadata
- named before it), and find the property (company
- named after it) that matches the clausePeanut
09/21/2021, 2:43 AMauthenticated
so that it uses RLS but now my secret JWT role can't access the view. How do I do both?
ALTER VIEW my_view OWNER TO authenticated;