pg_spec_helper 1.9.7 → 1.9.9
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/pg_spec_helper/enums.rb +2 -2
- data/lib/pg_spec_helper/functions.rb +8 -4
- data/lib/pg_spec_helper/models.rb +5 -1
- data/lib/pg_spec_helper/schemas.rb +1 -1
- data/lib/pg_spec_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eab4f11bd8ca2e846f2298687482bf2d28d6caabbd36515c7eebf9edef8663b0
|
4
|
+
data.tar.gz: e45ab0b87e3ebe1fdc515e4e28a92a116dd11c295584b4cac67ecc13e71b0425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b22f267ab7ad3e6e495cb92334094ace7b2304c054ab55bdec04561b339c2163afe9391170d04263c2683292ab3dcd8f239aa9d25fdcd953f7ed81b8ab566f29
|
7
|
+
data.tar.gz: 36e4342f390c36b28eb21a8a95a7e9b921529258561f1409e2689aadab4db7617bef8a73b0319a7a404dbc21195ae66edee378beba17bf37f28a85a159a5265c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.9.9](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.8...v1.9.9) (2023-08-24)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* creating model now sets correct null and default values ([2e4634e](https://github.com/craigulliott/pg_spec_helper/commit/2e4634ebac8bf52e7eca497e891e492179f6b98e))
|
9
|
+
|
10
|
+
## [1.9.8](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.7...v1.9.8) (2023-08-24)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* auto creating uuid-ossp extension if using create model ([bdc30a9](https://github.com/craigulliott/pg_spec_helper/commit/bdc30a95e4bbd2b5f8f347a10d29d874099997d6))
|
16
|
+
* only delete functions which were created (to prevent deleting internal functions) ([1c23a36](https://github.com/craigulliott/pg_spec_helper/commit/1c23a36b64992934214c21cdbf6200f74e172511))
|
17
|
+
|
3
18
|
## [1.9.7](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.6...v1.9.7) (2023-08-24)
|
4
19
|
|
5
20
|
|
data/lib/pg_spec_helper/enums.rb
CHANGED
@@ -32,11 +32,11 @@ class PGSpecHelper
|
|
32
32
|
rows.map { |row| row["enum_name"].to_sym }
|
33
33
|
end
|
34
34
|
|
35
|
-
# delete all enums
|
35
|
+
# delete all enums which were created by this helper
|
36
36
|
def delete_created_enums
|
37
37
|
@created_enums&.each do |enum|
|
38
38
|
connection.exec(<<~SQL)
|
39
|
-
DROP TYPE #{enum[:schema_name]}.#{enum[:enum_name]};
|
39
|
+
DROP TYPE IF EXISTS #{enum[:schema_name]}.#{enum[:enum_name]};
|
40
40
|
SQL
|
41
41
|
end
|
42
42
|
@created_enums = []
|
@@ -8,6 +8,9 @@ class PGSpecHelper
|
|
8
8
|
CREATE FUNCTION #{schema_name}.#{function_name}() returns trigger language plpgsql AS
|
9
9
|
$$#{function_definition.strip}$$;
|
10
10
|
SQL
|
11
|
+
# so we can delete them later
|
12
|
+
@created_functions ||= []
|
13
|
+
@created_functions << {schema_name: schema_name, function_name: function_name}
|
11
14
|
end
|
12
15
|
|
13
16
|
# return a list of function names for the provided schema
|
@@ -24,13 +27,14 @@ class PGSpecHelper
|
|
24
27
|
rows.map { |r| r["routine_name"].to_sym }
|
25
28
|
end
|
26
29
|
|
27
|
-
# delete all functions
|
28
|
-
def
|
29
|
-
|
30
|
+
# delete all functions which were created by this helper
|
31
|
+
def delete_created_functions
|
32
|
+
@created_functions&.each do |function|
|
30
33
|
connection.exec(<<~SQL)
|
31
|
-
DROP FUNCTION #{schema_name}.#{function_name};
|
34
|
+
DROP FUNCTION IF EXISTS #{function[:schema_name]}.#{function[:function_name]};
|
32
35
|
SQL
|
33
36
|
end
|
37
|
+
@created_functions = []
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
@@ -15,8 +15,12 @@ class PGSpecHelper
|
|
15
15
|
end
|
16
16
|
# create the table
|
17
17
|
create_table schema_name, table_name
|
18
|
+
# required for auto increment
|
19
|
+
connection.exec(<<~SQL)
|
20
|
+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
21
|
+
SQL
|
18
22
|
# create the standard columns
|
19
|
-
create_column schema_name, table_name, :id, :uuid,
|
23
|
+
create_column schema_name, table_name, :id, :uuid, false, "uuid_generate_v4()"
|
20
24
|
create_column schema_name, table_name, :created_at, :timestamp
|
21
25
|
create_column schema_name, table_name, :updated_at, :timestamp
|
22
26
|
# add the primary key
|