Skip to content

Commit

Permalink
Merge pull request #3291 from bgeuken/add_db_structure_sql_linter
Browse files Browse the repository at this point in the history
[ci] Add a linter for the structure.sql
  • Loading branch information
Ana06 committed Jun 28, 2017
2 parents 59e2829 + 11f5a31 commit aabb5cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions dist/ci/travis_script.sh
Expand Up @@ -33,6 +33,7 @@ if test -z "$SUBTEST"; then
bundle exec rails test:spider
;;
linter)
bundle exec rake db:structure:verify
make -C ../../ rubocop
bundle exec rake haml_lint
jshint .
Expand Down
14 changes: 14 additions & 0 deletions src/api/lib/tasks/databases.rake
Expand Up @@ -83,6 +83,20 @@ namespace :db do
end
File.open("#{Rails.root}/db/structure.sql", "w+") { |f| f << new_structure }
end

desc "Verify that structure.sql in git is up to date"
task verify: :environment do
puts "Running rails db:migrate"
Rake::Task["db:migrate"].invoke
puts "Diffing the db/structure.sql"
sh %{git diff --quiet db/structure.sql} do |ok, _|
unless ok
abort "Generated structure.sql differs from structure.sql stored in git. " +
"Please run rake db:migrate and check the differences."
end
end
puts "Everything looks fine!"
end
end

desc 'Create the database, load the structure, and initialize with the seed data'
Expand Down

0 comments on commit aabb5cb

Please sign in to comment.