schema_linter 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '005249a95eec766cfdaf1d61ef1e1214785bbaf2045d7c065cad8dbe4d866638'
4
+ data.tar.gz: 7547d762dcec8b45af32f6640250a070f6948457fef87ceadb8edef0594121da
5
+ SHA512:
6
+ metadata.gz: dc45dfbb4ce44a8bc388d5e8ae48ef61f66ee063020c9201fce6595c7a568b5317182a5942b5b9cdf832c93504632d23109f14067bb817d1fb1cd0938d08ee7c
7
+ data.tar.gz: 708b8ebaa63b850071300b141c3440fd930a41fe7d8f12320244f71d60da4f988855c0c23dcda28c27e9c9b33a3c469d3a70e5b5908b89f86e31f20cec22c564
@@ -0,0 +1,52 @@
1
+ version: 2.1
2
+
3
+ executors:
4
+ default:
5
+ working_directory: ~/app
6
+ docker:
7
+ - image: cimg/ruby:3.2.2
8
+ environment:
9
+ DB_USER: 'root'
10
+ DB_PASS: 'root'
11
+ DB_HOST: '127.0.0.1'
12
+ - image: circleci/mysql:8-ram
13
+ environment:
14
+ MYSQL_ROOT_PASSWORD: root
15
+ MYSQL_DATABASE: schema_linter_test
16
+ command: [--default-authentication-plugin=mysql_native_password]
17
+
18
+ commands:
19
+ setup_bundle:
20
+ steps:
21
+ - restore_cache:
22
+ key: bundle-{{ checksum "schema_linter.gemspec" }}
23
+ - run:
24
+ name: install dependencies
25
+ command: |
26
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
27
+ - save_cache:
28
+ key: bundle-{{ checksum "schema_linter.gemspec" }}
29
+ paths:
30
+ - vendor/bundle
31
+
32
+ wait_for_db:
33
+ steps:
34
+ - run:
35
+ name: Wait for DB
36
+ command: dockerize -wait tcp://127.0.0.1:3306 -timeout 1m
37
+
38
+ jobs:
39
+ test:
40
+ executor: default
41
+ steps:
42
+ - checkout
43
+ - setup_bundle
44
+ - wait_for_db
45
+ - run: bundle exec rspec ./spec
46
+
47
+ workflows:
48
+ version: 2
49
+
50
+ test:
51
+ jobs:
52
+ - test
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in schema_linter.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Akira Kusumoto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # schema_linter
2
+
3
+ This tool inspects whether the database schema contains any reserved words from MySQL or PostgreSQL, or any table names and column names that should not be used in Rails. Furthermore,
4
+ it allows for the definition of custom settings using custom definition rules in the YAML configuration file.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your Gemfile:
9
+ ```
10
+ gem 'schema_linter'
11
+ ```
12
+
13
+ Then run:
14
+ ```
15
+ % bundle
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ Simply execute the following command in your Rails app directory.
21
+
22
+ ```
23
+ % rake schema_linter
24
+ ```
25
+
26
+ If you want the rake task to fail when it encounters errors, use:
27
+
28
+ ```
29
+ % FAIL_ON_ERROR=1 rake schema_linter
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ Create a `.schema_linter.yaml` or `.schema_linter.yml` file in your root directory.
35
+
36
+ To flag specific tables as errors, list them with regular expressions under `error_table_names`.
37
+ To flag specific columns as errors, list them with regular expressions under `error_column_names`.
38
+
39
+ ```yaml
40
+ error_table_names:
41
+ - .*histories$
42
+ - .*info$
43
+
44
+ error_column_names:
45
+ - .*data$
46
+ ```
47
+
48
+ To exclude specific tables from the checks, list them with regular expressions under ignore_table_names.
49
+ To exclude specific columns from the checks, list them with regular expressions under ignore_column_names.
50
+
51
+ ```yaml
52
+ ignore_table_names:
53
+ - ^user$
54
+
55
+ ignore_column_names:
56
+ - ^role$
57
+ ```
58
+
59
+ ## Copyright
60
+
61
+ Copyright (c) 2023 Akira Kusumoto. See MIT-LICENSE file for further details.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec