pg_spec_helper 1.9.4 → 1.9.6

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: b4aa2aee2053fb4f9a129d26cb0312b6661012bdfb7c2204d89be74533459421
4
- data.tar.gz: 75e5870dfba01ac6b8dd545315d2f0d0131d02b0c4908e35e5c967c702ff97ca
3
+ metadata.gz: e3b62da006b35dbea8daca7fdd3bd4d3e13ce98492f58d482e652b79d97b3f8f
4
+ data.tar.gz: 3f4220fc53329992304b3987305f71d06ff8522502f940d214b48835d2022502
5
5
  SHA512:
6
- metadata.gz: b76f0a2b4f6d97a5ce7d7fb08b4a3e9b85a564db9b96f0a48db240ba3150ba9f83460a2e71e1523287d15134bef257698796cc3fd094d7e8035a9b77d7512689
7
- data.tar.gz: f9c007962259c976c856b75fd2922bbbf45e200a1179f4c8ec306d01033df905933af83124713042b225792ce4f6f882b6f3f1c486077e5b5db6fcda0e58ce32
6
+ metadata.gz: 7be14d2cc0e8249d17fe46807779db16bee0aedac36be575b9f338c1b6454b11e19dc2263cd01b0c3f0b3c0602c78c6029d7ead1d5847a741e24eb24a6da8979
7
+ data.tar.gz: 505d2929712d1d6b7abde81eb9e7ffe9ff65f2a87e1e782a3df73456ba3e541dfcba6ea8792869884576cd5271028b8c76c62ce15104c62d5ae51c410b2065c6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.9.6](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.5...v1.9.6) (2023-08-24)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * create columns with default values ([91e05b8](https://github.com/craigulliott/pg_spec_helper/commit/91e05b8b14c38161965ab8e2dc1d7e869e399567))
9
+ * fixed mistake in type signatures ([a2e5f1e](https://github.com/craigulliott/pg_spec_helper/commit/a2e5f1ed897dbd7968716126ccd6a675cc7a5641))
10
+
11
+ ## [1.9.5](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.4...v1.9.5) (2023-08-24)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * only deleting types which were created by us to prevent deleting non enums or types required by materialized views ([2ad6ff6](https://github.com/craigulliott/pg_spec_helper/commit/2ad6ff6ab5edff95bceafb5e646dd2b2f4f0729f))
17
+
3
18
  ## [1.9.4](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.3...v1.9.4) (2023-08-23)
4
19
 
5
20
 
@@ -6,11 +6,13 @@ class PGSpecHelper
6
6
  end
7
7
 
8
8
  # create a column for the provided table
9
- def create_column schema_name, table_name, column_name, type, null = true
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
12
  ALTER TABLE #{connection.quote_ident schema_name.to_s}.#{connection.quote_ident table_name.to_s}
13
- ADD COLUMN #{connection.quote_ident column_name.to_s} #{type} #{null ? "" : "NOT NULL"}
13
+ ADD COLUMN #{connection.quote_ident column_name.to_s} #{type}
14
+ #{null ? "" : "NOT NULL"}
15
+ #{default ? "DEFAULT #{default}" : ""}
14
16
  SQL
15
17
  end
16
18
 
@@ -7,6 +7,9 @@ class PGSpecHelper
7
7
  connection.exec(<<~SQL)
8
8
  CREATE TYPE #{schema_name}.#{enum_name} as ENUM ('#{values.join("','")}')
9
9
  SQL
10
+ # so we can delete them later
11
+ @created_enums ||= []
12
+ @created_enums << {schema_name: schema_name, enum_name: enum_name}
10
13
  end
11
14
 
12
15
  # Drop an enum
@@ -30,12 +33,13 @@ class PGSpecHelper
30
33
  end
31
34
 
32
35
  # delete all enums in the provided schema
33
- def delete_enums schema_name
34
- get_enum_names(schema_name).each do |enum_name|
36
+ def delete_created_enums
37
+ @created_enums&.each do |enum|
35
38
  connection.exec(<<~SQL)
36
- DROP TYPE #{schema_name}.#{enum_name};
39
+ DROP TYPE #{enum[:schema_name]}.#{enum[:enum_name]};
37
40
  SQL
38
41
  end
42
+ @created_enums = []
39
43
  end
40
44
  end
41
45
  end
@@ -16,7 +16,7 @@ class PGSpecHelper
16
16
  # create the table
17
17
  create_table schema_name, table_name
18
18
  # create the standard columns
19
- create_column schema_name, table_name, :id, :serial
19
+ create_column schema_name, table_name, :id, :uuid, null: false, default: "uuid_generate_v4()"
20
20
  create_column schema_name, table_name, :created_at, :timestamp
21
21
  create_column schema_name, table_name, :updated_at, :timestamp
22
22
  # add the primary key
@@ -39,7 +39,7 @@ class PGSpecHelper
39
39
  # delete all the tables, functions and enums from within the public schema
40
40
  delete_tables :public
41
41
  delete_functions :public
42
- delete_enums :public
42
+ delete_created_enums
43
43
  end
44
44
 
45
45
  def schema_exists? schema_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PGSpecHelper
4
- VERSION = "1.9.4"
4
+ VERSION = "1.9.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_spec_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.4
4
+ version: 1.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-23 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg