sqldef-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bebf6ded67228c38e91276d345c575bf01c586173af711c9f8104755c3bb11fd
4
+ data.tar.gz: bae5639ea7f527cd19fec4087ee541ddb73f171000a55e4c77a5c04cf29f9330
5
+ SHA512:
6
+ metadata.gz: 9df4dc3d271833f9cb786e2ea6743160310f3f4a9e0d9d467e87ea879d1d5cf7b2cf2863a6fd594880f0ca4a8941ab3eb3073022de3495b0738077d310c6e405
7
+ data.tar.gz: a9e17526b928590d6883cb2e6c17ba809b0f57a28268ab635cd37b6b7afaabdb2a941672bef6a104421367fd29e245bb82abbf89bea1b26470704edea61c6a6c
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.2.3
17
+ bundle install
18
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in sqldef-rails.gemspec
6
+ gemspec
7
+
8
+ gem 'rake'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Takashi Kokubun
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # sqldef-rails
2
+
3
+ Run [sqldef](https://github.com/k0kubun/sqldef) with config/database.yml.
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ gem 'sqldef-rails'
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ bundle exec rake db:migrate
15
+ ```
16
+
17
+ ## License
18
+
19
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "sqldef/rails"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ require 'sqldef'
3
+ require 'sqldef/rails/version'
4
+ require 'sqldef/rails/railtie'
@@ -0,0 +1,12 @@
1
+ require 'rails/railtie'
2
+
3
+ class Sqldef::Rails::Railtie < ::Rails::Railtie
4
+ initializer :sqldef do |app|
5
+ Sqldef.bin = Rails.root.join('bin').to_s
6
+ end
7
+
8
+ rake_tasks do
9
+ load File.expand_path('./tasks/sqldef.rake', __dir__)
10
+ load File.expand_path('./tasks/databases.rake', __dir__)
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rake::Task.tasks.each do |task|
4
+ case task.name
5
+ when /\Adb:schema:/, /\Adb:migrate(:|\z)/, 'db:rollback'
6
+ task.clear
7
+ end
8
+ end
9
+
10
+ namespace :db do
11
+ {
12
+ 'migrate:status' => 'sqldef:dry-run',
13
+ 'migrate' => 'sqldef:apply',
14
+ 'schema:load' => 'sqldef:apply',
15
+ 'schema:dump' => 'sqldef:export',
16
+ }.each do |db, sqldef|
17
+ desc Rake::Task[sqldef].comment
18
+ task db => sqldef
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :sqldef do
4
+ commands = {
5
+ 'mysql2' => :mysqldef,
6
+ 'postgresql' => :psqldef,
7
+ 'sqlite3' => :sqlite3def,
8
+ }
9
+
10
+ desc 'Export the database'
11
+ task export: [:environment] do
12
+ database = Rails.application.config_for(:database)
13
+ Sqldef.export(
14
+ host: database.fetch(:host),
15
+ port: database[:port],
16
+ user: database.fetch(:username),
17
+ password: database[:password],
18
+ database: database.fetch(:database),
19
+ command: commands.fetch(database.fetch(:adapter)),
20
+ path: Rails.root.join('db/schema.sql').to_s,
21
+ )
22
+ end
23
+
24
+ desc 'Dry-run the database'
25
+ task 'dry-run': [:environment] do
26
+ database = Rails.application.config_for(:database)
27
+ Sqldef.dry_run(
28
+ host: database.fetch(:host),
29
+ port: database[:port],
30
+ user: database.fetch(:username),
31
+ password: database[:password],
32
+ database: database.fetch(:database),
33
+ command: commands.fetch(database.fetch(:adapter)),
34
+ path: Rails.root.join('db/schema.sql').to_s,
35
+ )
36
+ end
37
+
38
+ desc 'Apply the database'
39
+ task apply: [:environment] do
40
+ database = Rails.application.config_for(:database)
41
+ Sqldef.apply(
42
+ host: database.fetch(:host),
43
+ port: database[:port],
44
+ user: database.fetch(:username),
45
+ password: database[:password],
46
+ database: database.fetch(:database),
47
+ command: commands.fetch(database.fetch(:adapter)),
48
+ path: Rails.root.join('db/schema.sql').to_s,
49
+ )
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sqldef
4
+ module Rails
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/sqldef/rails/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'sqldef-rails'
7
+ spec.version = Sqldef::Rails::VERSION
8
+ spec.authors = ['Takashi Kokubun']
9
+ spec.email = ['takashikkbn@gmail.com']
10
+
11
+ spec.summary = 'Idempotent MySQL/PostgreSQL schema management by SQL'
12
+ spec.description = 'Idempotent MySQL/PostgreSQL schema management by SQL'
13
+ spec.homepage = 'https://github.com/sqldef/sqldef-rails'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = spec.homepage
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_dependency 'sqldef'
30
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sqldef-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Takashi Kokubun
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sqldef
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Idempotent MySQL/PostgreSQL schema management by SQL
28
+ email:
29
+ - takashikkbn@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/workflows/main.yml"
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/setup
42
+ - lib/sqldef/rails.rb
43
+ - lib/sqldef/rails/railtie.rb
44
+ - lib/sqldef/rails/tasks/databases.rake
45
+ - lib/sqldef/rails/tasks/sqldef.rake
46
+ - lib/sqldef/rails/version.rb
47
+ - sqldef-rails.gemspec
48
+ homepage: https://github.com/sqldef/sqldef-rails
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ homepage_uri: https://github.com/sqldef/sqldef-rails
53
+ source_code_uri: https://github.com/sqldef/sqldef-rails
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.3.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.2.3
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Idempotent MySQL/PostgreSQL schema management by SQL
73
+ test_files: []