bug fixed

This commit is contained in:
병준 박 2022-08-11 06:37:30 +00:00
parent 7a46f34f1d
commit dd88c522e8
4 changed files with 21 additions and 0 deletions

View File

@ -2,3 +2,4 @@ DROP EXTENSION "uuid-ossp";
DROP FUNCTION update_updated_at_column; DROP FUNCTION update_updated_at_column;
DROP FUNCTION update_state_changed_at_column; DROP FUNCTION update_state_changed_at_column;
DROP FUNCTION update_active_changed_at_column; DROP FUNCTION update_active_changed_at_column;
DROP FUNCTION update_last_signined_at_column;

View File

@ -34,3 +34,15 @@ BEGIN
END; END;
$$ language 'plpgsql'; $$ language 'plpgsql';
CREATE OR REPLACE FUNCTION update_last_signined_at_column()
RETURNS TRIGGER AS $$
BEGIN
IF OLD.last_signined_ip != NEW.last_signined_ip THEN
NEW.last_signined_at = (extract(epoch from now()) * 1000);
ELSE
NEW.last_signined_at = NEW.last_signined_at;
END IF;
RETURN NEW;
END;
$$ language 'plpgsql';

View File

@ -1,4 +1,5 @@
DROP INDEX idx_members_username; DROP INDEX idx_members_username;
DROP TRIGGER tg_members_last_signined_at;
DROP TRIGGER tg_members_state_changed_at; DROP TRIGGER tg_members_state_changed_at;
DROP TRIGGER tg_members_updated_at; DROP TRIGGER tg_members_updated_at;
DROP TABLE members; DROP TABLE members;

View File

@ -51,3 +51,10 @@ CREATE TRIGGER tg_members_state_changed_at
ON members ON members
FOR EACH ROW FOR EACH ROW
EXECUTE PROCEDURE update_state_changed_at_column(); EXECUTE PROCEDURE update_state_changed_at_column();
-- trigger (state_changed_at)
CREATE TRIGGER tg_members_last_signined_at
BEFORE UPDATE
ON members
FOR EACH ROW
EXECUTE PROCEDURE update_last_signined_at_column();