db_schema_checker 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a92e910735ae32eb61ca954fdb37755ea7db087c
4
- data.tar.gz: 45f24f4f79c8696e1b99ca5a17204d16a389877d
2
+ SHA256:
3
+ metadata.gz: 748dd451accb154e6ff05f94eac4a3f02294abcfae872117fbf2c7e8aef75d4b
4
+ data.tar.gz: b5dd01a077594665f402507a72537383b08013408eaf9e79a7a012d3f1cf5cef
5
5
  SHA512:
6
- metadata.gz: 1ea894b56fd58b797e2f29cf97188a0834f0a3b8b36f69b4824189e7b34e7e470110357f905b33f3ca38dc8892f23b6dda3fab4052091422b07050137fb61dc5
7
- data.tar.gz: eebc8f3b55bb687d97385faf3d8e00cfbda1bfb5488b472499e82e29617e7163d0af8e4cc9b8af635499551039875d12e009a588fef2cf0a8f9e6251978e79cf
6
+ metadata.gz: 664bde7b6ae101509e6c8b388f5a818fc2ce3a3ee4bb2c3c7a48f7539b1aea7888f8a40ac413fc8d48a2ee00b098e3e3530e96f485154e1185c2e420eb50df75
7
+ data.tar.gz: b06df408a021ce6dd3195a84cf08521ed89beeddcdc5cf9924303daa131a8ca9b6932310a395a5535e3e53024fd77afa8ff06c57c711310308510f393ff0373c
@@ -0,0 +1,37 @@
1
+ # This is a comment.
2
+ # Each line is a file pattern followed by one or more owners.
3
+
4
+ # These owners will be the default owners for everything in
5
+ # the repo. Unless a later match takes precedence,
6
+ # @global-owner1 and @global-owner2 will be requested for
7
+ # review when someone opens a pull request.
8
+ * @meganemura
9
+
10
+ # Order is important; the last matching pattern takes the most
11
+ # precedence. When someone opens a pull request that only
12
+ # modifies JS files, only @js-owner and not the global
13
+ # owner(s) will be requested for a review.
14
+ # *.js @js-owner
15
+
16
+ # You can also use email addresses if you prefer. They'll be
17
+ # used to look up users just like we do for commit author
18
+ # emails.
19
+ # *.go docs@example.com
20
+
21
+ # In this example, @doctocat owns any files in the build/logs
22
+ # directory at the root of the repository and any of its
23
+ # subdirectories.
24
+ # /build/logs/ @doctocat
25
+
26
+ # The `docs/*` pattern will match files like
27
+ # `docs/getting-started.md` but not further nested files like
28
+ # `docs/build-app/troubleshooting.md`.
29
+ # docs/* docs@example.com
30
+
31
+ # In this example, @octocat owns any file in an apps directory
32
+ # anywhere in your repository.
33
+ # apps/ @octocat
34
+
35
+ # In this example, @doctocat owns any file in the `/docs`
36
+ # directory in the root of your repository.
37
+ # /docs/ @doctocat
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ Gemfile.lock
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at dev@smarthr.jp. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/README.md CHANGED
@@ -20,13 +20,16 @@ $ RAILS_ENV=test bin/rails db:migrate:reset:check
20
20
  Dropped database 'blog_test'
21
21
  Created database 'blog_test'
22
22
  ERROR: Generated schema is not consistent with db/schema.rb
23
- ok
24
23
  ```
25
24
 
26
25
  ## Contributing
27
26
 
28
27
  Bug reports and pull requests are welcome on GitHub at https://github.com/kufu/db_schema_checker.
29
28
 
29
+ ## Code of Conduct
30
+
31
+ Everyone interacting in the db_schema_checker project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kufu/db_schema_checker/blob/master/CODE_OF_CONDUCT.md).
32
+
30
33
  ## License
31
34
 
32
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
35
+ The gem is available as open source under the terms of the [MIT License](https://github.com/kufu/db_schema_checker/blob/master/LICENSE.txt).
data/Rakefile CHANGED
@@ -1,6 +1 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -16,11 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
- spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
19
  spec.require_paths = ["lib"]
22
20
 
23
- spec.add_development_dependency "bundler", "~> 1.16"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.0"
21
+ spec.add_development_dependency "rake"
26
22
  end
@@ -1,3 +1,3 @@
1
1
  module DbSchemaChecker
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -10,17 +10,35 @@ namespace :db do
10
10
  original_env_schema = ENV['SCHEMA']
11
11
  original_env_verbose = ENV['VERBOSE']
12
12
 
13
+ schema_format = if ActiveRecord.gem_version < Gem::Version.create('7.0.0')
14
+ ActiveRecord::Base.schema_format
15
+ else
16
+ ActiveRecord.schema_format
17
+ end
18
+
19
+ schema_path = if schema_format == :ruby
20
+ 'db/schema.rb'
21
+ else
22
+ 'db/structure.sql'
23
+ end
24
+
13
25
  consistent = nil
26
+ diff = ''
14
27
  Dir.mktmpdir(nil, Rails.root.join('tmp')) do |dir|
15
- schema_rb = Rails.root.join('db', 'schema.rb')
16
- generated_schema = File.join(dir, 'schema.rb')
28
+ old_schema = Rails.root.join(schema_path)
29
+ new_schema = File.join(dir, File.basename(schema_path))
17
30
 
18
- ENV['SCHEMA'] = generated_schema
31
+ ENV['SCHEMA'] = new_schema
19
32
  ENV['VERBOSE'] = 'false'
20
33
 
21
34
  Rake::Task['db:migrate:reset'].invoke
22
35
 
23
- consistent = FileUtils.compare_file(schema_rb, generated_schema)
36
+ consistent = FileUtils.compare_file(old_schema, new_schema)
37
+
38
+ next if consistent
39
+ next if `which diff`.empty?
40
+
41
+ diff = `diff -u #{old_schema} #{new_schema}`
24
42
  end
25
43
 
26
44
  ENV['SCHEMA'] = original_env_schema
@@ -31,6 +49,7 @@ namespace :db do
31
49
  exit 0
32
50
  else
33
51
  puts 'ERROR: Generated schema is not consistent with db/schema.rb'
52
+ puts diff
34
53
  exit 1
35
54
  end
36
55
  end
metadata CHANGED
@@ -1,57 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_schema_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - meganemura
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-07 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.16'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
17
+ - - ">="
46
18
  - !ruby/object:Gem::Version
47
- version: '3.0'
19
+ version: '0'
48
20
  type: :development
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
- - - "~>"
24
+ - - ">="
53
25
  - !ruby/object:Gem::Version
54
- version: '3.0'
26
+ version: '0'
55
27
  description: Check the consistency of generated schema.rb
56
28
  email:
57
29
  - meganemura@users.noreply.github.com
@@ -59,15 +31,15 @@ executables: []
59
31
  extensions: []
60
32
  extra_rdoc_files: []
61
33
  files:
34
+ - ".github/CODEOWNERS"
62
35
  - ".gitignore"
63
36
  - ".rspec"
64
37
  - ".travis.yml"
38
+ - CODE_OF_CONDUCT.md
65
39
  - Gemfile
66
40
  - LICENSE.txt
67
41
  - README.md
68
42
  - Rakefile
69
- - bin/console
70
- - bin/setup
71
43
  - db_schema_checker.gemspec
72
44
  - lib/db_schema_checker.rb
73
45
  - lib/db_schema_checker/railtie.rb
@@ -92,8 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
64
  - !ruby/object:Gem::Version
93
65
  version: '0'
94
66
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.6.14
67
+ rubygems_version: 3.1.6
97
68
  signing_key:
98
69
  specification_version: 4
99
70
  summary: Check the consistency of generated schema.rb
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "db_schema_checker"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here