pg_spec_helper 1.9.7 → 1.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/pg_spec_helper/columns.rb +1 -0
- data/lib/pg_spec_helper/enums.rb +2 -2
- data/lib/pg_spec_helper/functions.rb +8 -4
- 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: 718445dba71c4a5574251f19ca1da659e7961e065467d94cc2b1375661edb340
|
4
|
+
data.tar.gz: 1005b96612ed0402a9724c2a9acceb8a2c5d4e8feda8a8ab37a9f7fe73de101c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87c640fcf85228a1bc97fd1dbb34b2b15fe65aa4c5cf7e89aa7ce8a60bea86686009f0796cd107b2e7a9088f30e88575c20aa8144628939afbc71a28a0acb534
|
7
|
+
data.tar.gz: 0e5a77f800f9cbf9532eeec39f20a7b6821dafeb28565a21ebae3786f1afc81222839f34e7489e80b8889c7652fe5410d047fe4bcecd70fd70c97e117bf1fc45
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.9.8](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.7...v1.9.8) (2023-08-24)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* auto creating uuid-ossp extension if using create model ([bdc30a9](https://github.com/craigulliott/pg_spec_helper/commit/bdc30a95e4bbd2b5f8f347a10d29d874099997d6))
|
9
|
+
* only delete functions which were created (to prevent deleting internal functions) ([1c23a36](https://github.com/craigulliott/pg_spec_helper/commit/1c23a36b64992934214c21cdbf6200f74e172511))
|
10
|
+
|
3
11
|
## [1.9.7](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.6...v1.9.7) (2023-08-24)
|
4
12
|
|
5
13
|
|
@@ -9,6 +9,7 @@ class PGSpecHelper
|
|
9
9
|
def create_column schema_name, table_name, column_name, type, null = true, default = nil
|
10
10
|
# note the `type` is safe from sql_injection due to the validation above
|
11
11
|
connection.exec(<<~SQL)
|
12
|
+
create extension if not exists "uuid-ossp";
|
12
13
|
ALTER TABLE #{connection.quote_ident schema_name.to_s}.#{connection.quote_ident table_name.to_s}
|
13
14
|
ADD COLUMN #{connection.quote_ident column_name.to_s} #{type}
|
14
15
|
#{null ? "" : "NOT NULL"}
|
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
|