File tree 2 files changed +28
-0
lines changed 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ def generate
22
22
write_db_schema ( config , header , schema )
23
23
write_db_models ( config , header , schema )
24
24
25
+ validate_schema ( db )
26
+
25
27
puts "Done"
26
28
end
27
29
@@ -83,6 +85,19 @@ def load_config_file(db)
83
85
YAML . load_file ( config_path , symbolize_names : true )
84
86
end
85
87
88
+ def validate_schema ( type )
89
+ Tempfile . create do |tempfile |
90
+ begin
91
+ ::Migrations ::Database . migrate (
92
+ tempfile ,
93
+ migrations_path : ::Migrations ::Database . schema_path ( type ) ,
94
+ )
95
+ rescue Extralite ::SQLError => e
96
+ print_error ( "Invalid schema: #{ e . message } " )
97
+ end
98
+ end
99
+ end
100
+
86
101
def print_error ( message )
87
102
$stderr. puts "ERROR: " . red + message
88
103
end
Original file line number Diff line number Diff line change @@ -31,6 +31,19 @@ def self.connect(path)
31
31
nil
32
32
end
33
33
34
+ def self . schema_path ( type )
35
+ case type
36
+ when "intermediate_db"
37
+ INTERMEDIATE_DB_SCHEMA_PATH
38
+ when "mappings_db"
39
+ MAPPINGS_DB_SCHEMA_PATH
40
+ when "uploads_db"
41
+ UPLOADS_DB_SCHEMA_PATH
42
+ else
43
+ raise "Unknown type: #{ type } "
44
+ end
45
+ end
46
+
34
47
def self . format_datetime ( value )
35
48
value &.utc &.iso8601
36
49
end
You can’t perform that action at this time.
0 commit comments