@pgpm/stamps 0.21.0 → 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 CHANGED
@@ -1,5 +1,5 @@
1
1
  EXTENSION = pgpm-stamps
2
- DATA = sql/pgpm-stamps--0.15.3.sql
2
+ DATA = sql/pgpm-stamps--0.15.5.sql
3
3
 
4
4
  PG_CONFIG = pg_config
5
5
  PGXS := $(shell $(PG_CONFIG) --pgxs)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpm/stamps",
3
- "version": "0.21.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.21.0",
25
- "@pgpm/verify": "0.21.0"
24
+ "@pgpm/jwt-claims": "0.22.0",
25
+ "@pgpm/verify": "0.22.0"
26
26
  },
27
27
  "devDependencies": {
28
- "pgpm": "^4.2.3"
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": "f79dd69a3f7bac456bbd4474262b0ccbdb3e66a3"
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;