@@ -9,6 +9,7 @@ Say good-bye to those pesky diffs you get between coworkers!
9
9
10
10
By default, it will:
11
11
12
+ * remove ` \restrict ` and ` \unrestrict ` pragmas
12
13
* Inline primary key declarations
13
14
* Inline SERIAL type declarations
14
15
* Inline table constraints
@@ -27,6 +28,8 @@ As an example, the task will transform this raw `structure.sql`:
27
28
<summary >Click to expand</summary >
28
29
29
30
``` sql
31
+ \restrict 1234
32
+
30
33
--
31
34
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
32
35
--
@@ -261,6 +264,10 @@ If you want to configure which transforms to use, you can configure the library
261
264
262
265
``` ruby
263
266
Rails .application.configure do
267
+ config.activerecord_pg_format_db_structure.preprocessors = [
268
+ Preprocessors ::RemoveRestrictPragmas
269
+ ]
270
+
264
271
config.activerecord_pg_format_db_structure.transforms = [
265
272
ActiveRecordPgFormatDbStructure ::Transforms ::RemoveCommentsOnExtensions ,
266
273
ActiveRecordPgFormatDbStructure ::Transforms ::RemoveDefaultsSetCommands ,
@@ -271,7 +278,7 @@ Rails.application.configure do
271
278
ActiveRecordPgFormatDbStructure ::Transforms ::InlineConstraints ,
272
279
ActiveRecordPgFormatDbStructure ::Transforms ::MoveIndicesAfterCreateTable ,
273
280
ActiveRecordPgFormatDbStructure ::Transforms ::GroupAlterTableStatements ,
274
- ActiveRecordPgFormatDbStructure ::Transforms ::SortTableColumns ,
281
+ ActiveRecordPgFormatDbStructure ::Transforms ::SortTableColumns
275
282
]
276
283
277
284
config.activerecord_pg_format_db_structure.deparser = ActiveRecordPgFormatDbStructure ::Deparser
@@ -287,6 +294,13 @@ structure = File.read("db/structure.sql")
287
294
formatted = ActiveRecordPgFormatDbStructure ::Formatter .new .format (structure)
288
295
File .write(" db/structure.sql" , formatted)
289
296
```
297
+ ## Preprocessors
298
+
299
+ ### RemoveRestrictPragmas
300
+
301
+ Remove ` \restrict ` and ` \unrestrict ` pragmas that were added in newer
302
+ versions of ` pg_dump ` , since they are not valid SQL syntax and
303
+ therefore prevent parsing the file as SQL.
290
304
291
305
## Transformers
292
306
0 commit comments