quivr/scripts/202308181004030_rename_users_table.sql
Zineb El Bachiri 9aaedcff51
Fix/requests limiting (#980)
* 🗃️ Rename users table into user_daily_usage

* 💥 replace User model with UserIdentity model

* 🗃️ New UserDailyUsage class for database interaction

* 🐛 fix daily requests rate limiting per user

* 🐛 fix user stats and properties update

* ✏️ add typing and linting

* 🚚 rename user_dialy_usage Class  into user_usage & requests_count into daily_requests_count

* 🚑 fix some rebase errors
2023-08-21 14:05:13 +02:00

29 lines
532 B
SQL

-- Create a new user_daily_usage table
create table if not exists
user_daily_usage (
user_id uuid references auth.users (id),
email text,
date text,
daily_requests_count int,
primary key (user_id, date)
);
-- Drop the old users table
drop table if exists users;
-- Update migrations table
insert into
migrations (name)
select
'202308181004030_rename_users_table'
where
not exists (
select
1
from
migrations
where
name = '202308181004030_rename_users_table'
);
commit;