bug fixed
This commit is contained in:
parent
7a46f34f1d
commit
dd88c522e8
|
@ -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;
|
||||||
|
|
|
@ -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';
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user