pg_spec_helper 1.9.5 → 1.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/pg_spec_helper/columns.rb +4 -2
- data/lib/pg_spec_helper/models.rb +2 -2
- 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: 8e7cbe1ac44df56e5c441603bed08618176afe0a5078e59dfd73b46344ca0905
|
4
|
+
data.tar.gz: aecb8f4db0504277d433a222999224b4a797eceae3e296d758bada2aa065e530
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b20b76783e605290fe3878ca214d747e46f5e928ce737ed627c6d9a4f1e5b81f1f20a71f6df3d5a237c6181db928140c8cef4d26360dafb5aed9e52dd16109e6
|
7
|
+
data.tar.gz: 448c1f7e682e780ebbbdf5f3139e6905e347dc711fe396909a2af0314dcd237831900bdae409350f6b65f1f91b2b5076a831cbcf36039522e2c97cf19e518f7e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.9.7](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.6...v1.9.7) (2023-08-24)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* ensuring uniqueness for primary_keys ([6179b46](https://github.com/craigulliott/pg_spec_helper/commit/6179b46f683adf08836c7193dd63711fe2533778))
|
9
|
+
|
10
|
+
## [1.9.6](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.5...v1.9.6) (2023-08-24)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* create columns with default values ([91e05b8](https://github.com/craigulliott/pg_spec_helper/commit/91e05b8b14c38161965ab8e2dc1d7e869e399567))
|
16
|
+
* fixed mistake in type signatures ([a2e5f1e](https://github.com/craigulliott/pg_spec_helper/commit/a2e5f1ed897dbd7968716126ccd6a675cc7a5641))
|
17
|
+
|
3
18
|
## [1.9.5](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.4...v1.9.5) (2023-08-24)
|
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}
|
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
|
|
@@ -16,11 +16,11 @@ 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, :
|
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
|
23
|
-
create_primary_key schema_name, table_name, [:id], :
|
23
|
+
create_primary_key schema_name, table_name, [:id], :"#{table_name}_pkey"
|
24
24
|
# execute the optional block
|
25
25
|
if block
|
26
26
|
this = self
|