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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e7cbe1ac44df56e5c441603bed08618176afe0a5078e59dfd73b46344ca0905
4
- data.tar.gz: aecb8f4db0504277d433a222999224b4a797eceae3e296d758bada2aa065e530
3
+ metadata.gz: 718445dba71c4a5574251f19ca1da659e7961e065467d94cc2b1375661edb340
4
+ data.tar.gz: 1005b96612ed0402a9724c2a9acceb8a2c5d4e8feda8a8ab37a9f7fe73de101c
5
5
  SHA512:
6
- metadata.gz: b20b76783e605290fe3878ca214d747e46f5e928ce737ed627c6d9a4f1e5b81f1f20a71f6df3d5a237c6181db928140c8cef4d26360dafb5aed9e52dd16109e6
7
- data.tar.gz: 448c1f7e682e780ebbbdf5f3139e6905e347dc711fe396909a2af0314dcd237831900bdae409350f6b65f1f91b2b5076a831cbcf36039522e2c97cf19e518f7e
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"}
@@ -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 in the provided schema
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 in the provided schema
28
- def delete_functions schema_name
29
- get_function_names(schema_name).each do |function_name|
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
@@ -38,7 +38,7 @@ class PGSpecHelper
38
38
  end
39
39
  # delete all the tables, functions and enums from within the public schema
40
40
  delete_tables :public
41
- delete_functions :public
41
+ delete_created_functions
42
42
  delete_created_enums
43
43
  end
44
44
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PGSpecHelper
4
- VERSION = "1.9.7"
4
+ VERSION = "1.9.8"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_spec_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.7
4
+ version: 1.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott