update check

This commit is contained in:
ridethepig 2022-11-12 01:25:38 +08:00
parent fdbd8d3d7c
commit ef7a365287
3 changed files with 5 additions and 3 deletions

View File

@ -143,10 +143,12 @@ drop table if exists user_stat;
create table user_stat create table user_stat
( (
user_id int PRIMARY KEY, user_id int PRIMARY KEY,
user_limit int NOT NULL,
user_usedspace int NOT NULL DEFAULT 0, user_usedspace int NOT NULL DEFAULT 0,
user_bookcount int NOT NULL DEFAULT 0, user_bookcount int NOT NULL DEFAULT 0,
user_doccount int NOT NULL DEFAULT 0, user_doccount int NOT NULL DEFAULT 0,
user_notecount int NOT NULL DEFAULT 0, user_notecount int NOT NULL DEFAULT 0,
CONSTRAINT `fk_user_stat_user` FOREIGN KEY (`user_id`) REFERENCES user(`user_id`) ON DELETE RESTRICT CONSTRAINT `fk_user_stat_user` FOREIGN KEY (`user_id`) REFERENCES user(`user_id`) ON DELETE RESTRICT,
CONSTRAINT `ck_usedspace` CHECK (user_usedspace <= user_limit)
); );
-- insert into user_stat values (1,1,1,1,1); -- insert into user_stat values (1,1,1,1,1,1);

View File

@ -2,7 +2,7 @@ drop trigger if exists `trig_create_user_stat`;
create trigger `trig_create_user_stat` create trigger `trig_create_user_stat`
after insert on user after insert on user
for each row begin for each row begin
insert into user_stat (`user_id`) values(NEW.user_id); insert into user_stat (`user_id`, `user_limit`) values(NEW.user_id, NEW.user_limit);
end; end;
drop trigger if exists `trig_delete_user_stat`; drop trigger if exists `trig_delete_user_stat`;

Binary file not shown.