@pgpm/stamps 0.21.2 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +1 -1
- package/package.json +5 -5
- package/sql/pgpm-stamps--0.15.5.sql +33 -0
package/Makefile
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/stamps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Timestamp utilities and audit trail functions for PostgreSQL",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"test:watch": "jest --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pgpm/jwt-claims": "0.
|
|
25
|
-
"@pgpm/verify": "0.
|
|
24
|
+
"@pgpm/jwt-claims": "0.22.0",
|
|
25
|
+
"@pgpm/verify": "0.22.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"pgpm": "^4.
|
|
28
|
+
"pgpm": "^4.23.2"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/constructive-io/pgpm-modules/issues"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "96ae0195a8b3a3dd056808c344f0e3c31a199e5e"
|
|
39
39
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
\echo Use "CREATE EXTENSION pgpm-stamps" to load this file. \quit
|
|
2
|
+
CREATE SCHEMA stamps;
|
|
3
|
+
|
|
4
|
+
GRANT USAGE ON SCHEMA stamps TO authenticated, anonymous;
|
|
5
|
+
|
|
6
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA stamps
|
|
7
|
+
GRANT EXECUTE ON FUNCTIONS TO authenticated;
|
|
8
|
+
|
|
9
|
+
CREATE FUNCTION stamps.peoplestamps() RETURNS trigger AS $EOFCODE$
|
|
10
|
+
BEGIN
|
|
11
|
+
IF TG_OP = 'INSERT' THEN
|
|
12
|
+
NEW.created_by = jwt_public.current_user_id();
|
|
13
|
+
NEW.updated_by = jwt_public.current_user_id();
|
|
14
|
+
ELSIF TG_OP = 'UPDATE' THEN
|
|
15
|
+
NEW.created_by = OLD.created_by;
|
|
16
|
+
NEW.updated_by = jwt_public.current_user_id();
|
|
17
|
+
END IF;
|
|
18
|
+
RETURN NEW;
|
|
19
|
+
END;
|
|
20
|
+
$EOFCODE$ LANGUAGE plpgsql;
|
|
21
|
+
|
|
22
|
+
CREATE FUNCTION stamps.timestamps() RETURNS trigger AS $EOFCODE$
|
|
23
|
+
BEGIN
|
|
24
|
+
IF TG_OP = 'INSERT' THEN
|
|
25
|
+
NEW.created_at = NOW();
|
|
26
|
+
NEW.updated_at = NOW();
|
|
27
|
+
ELSIF TG_OP = 'UPDATE' THEN
|
|
28
|
+
NEW.created_at = OLD.created_at;
|
|
29
|
+
NEW.updated_at = NOW();
|
|
30
|
+
END IF;
|
|
31
|
+
RETURN NEW;
|
|
32
|
+
END;
|
|
33
|
+
$EOFCODE$ LANGUAGE plpgsql;
|