sequel-migrate 0.1.0-java

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
+ SHA1:
3
+ metadata.gz: 881221fb0d0324a1fb5ecff96c2f23f88924a3cf
4
+ data.tar.gz: 8aae5d0c9b16b5f23333ad63164f4d2f4cd84d90
5
+ SHA512:
6
+ metadata.gz: c299fb2d7f8c86d88a9f59c0210762d41fc3924fb0e1982336f68b41b803fce84a3e627bbc45cbd7e3365ce0197f77bfcf554882b87670ae78d46107d705713b
7
+ data.tar.gz: f760e6a7fae37160dffa9335c88e7050a4605b4e43f989e6d04348aec395633f56045500d89a760e99cfa88bb7dce855ca2eae22638ca98168b869653da805fd
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /db
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ jruby-9.1.6.0
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sequel-migrate.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Sequel::Migrate
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sequel/migrate`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'sequel-migrate'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install sequel-migrate
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sequel-migrate.
36
+
data/Rakefile ADDED
File without changes
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sequel/migrate"
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
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
data/bin/sm ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
4
+
5
+ require_relative '../lib/sequel/migrate'
6
+ require 'rake'
7
+ require 'sequel'
8
+ require 'active_support/inflector'
9
+ require 'pry'
10
+
11
+ app = Rake.application
12
+ app.init
13
+ app.add_import File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "tasks", "db.rake"))
14
+ app.add_import File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "tasks", "generate.rake"))
15
+ app.run
@@ -0,0 +1,5 @@
1
+ module Sequel
2
+ module Migrate
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ require "sequel/migrate/version"
2
+
3
+ module Sequel
4
+ module Migrate
5
+ end
6
+ end
data/lib/tasks/db.rake ADDED
@@ -0,0 +1,105 @@
1
+ namespace :db do
2
+ desc "Load environment"
3
+ task :environment do
4
+ if ENV['APP_ENV'] == "test" || ENV["RAILS_ENV"] == "test"
5
+ url = ENV['TEST_DATABASE_URL'] || ENV['TEST_MYSQL_URL']
6
+ else
7
+ url = ENV['DATABASE_URL'] || ENV['MYSQL_URL']
8
+ end
9
+
10
+ # some JVM drivers (finagle) don't put user/password in url but as different vars
11
+ # parse url and add user and password to query string as needed
12
+ if url.start_with?("jdbc")
13
+ is_jdbc = true
14
+ base_url = url.gsub(/^jdbc\:/, "")
15
+ else
16
+ is_jdbc = false
17
+ base_url = url
18
+ end
19
+
20
+ uri = URI.parse(base_url)
21
+ query = CGI.parse(uri.query)
22
+
23
+ if !query.has_key?("user")
24
+ query["user"] = ENV['DATABASE_USERNAME'] || ENV['MYSQL_USERNAME']
25
+ end
26
+ if !query.has_key?("password")
27
+ password = ENV['DATABASE_PASSWORD'] || ENV['MYSQL_PASSWORD']
28
+ query["password"] = password unless password.nil?
29
+ end
30
+
31
+ uri.query = URI.encode_www_form(query)
32
+
33
+ if is_jdbc
34
+ uri = "jdbc:" + uri.to_s
35
+ end
36
+
37
+ ::Sequel::Model.db = ::Sequel.connect(uri)
38
+ ::Sequel::Model.db.extension(:connection_validator)
39
+ ::Sequel::Model.db.pool.connection_validation_timeout = 300
40
+ end
41
+
42
+ desc "Generate ruby models for all tables"
43
+ task :generate_models => :environment do
44
+ Sequel::Model.db.tables.each do |table|
45
+ klass_name = table.to_s.camelize.singularize
46
+ klass = Class.new(Sequel::Model(table))
47
+ Object.const_set(klass_name, klass)
48
+ puts "Detected model #{table}"
49
+ end
50
+ end
51
+
52
+ desc "Load a console"
53
+ task :console => :generate_models do
54
+ Pry.start
55
+ end
56
+
57
+ desc "Show version"
58
+ task :version => :environment do
59
+ version = if Sequel::Model.db.tables.include?(:schema_migrations)
60
+ Sequel::Model.db[:schema_migrations].to_a.reverse.first
61
+ end || {}
62
+
63
+ puts "Schema Version: #{version[:filename]}"
64
+ end
65
+
66
+ desc "Migrate database"
67
+ task :migrate, [:version] => :environment do |_, args|
68
+ Sequel.extension :migration
69
+
70
+ if args[:version]
71
+ puts "Migrating to version #{args[:version]}"
72
+ Sequel::Migrator.run(Sequel::Model.db, "db/migrate", target: args[:version].to_i)
73
+ else
74
+ puts "Migrating to latest"
75
+ Sequel::Migrator.run(Sequel::Model.db, "db/migrate")
76
+ end
77
+
78
+ Rake::Task['db:version'].execute
79
+ end
80
+
81
+ desc "Rollback database"
82
+ task :rollback, [:version] => :environment do |_, args|
83
+ Sequel.extension :migration
84
+
85
+ version = if Sequel::Model.db.tables.include?(:schema_migrations)
86
+ Sequel::Model.db[:schema_migrations].to_a.sort_by{|x| x["filename"]}.reverse[1]
87
+ end || {}
88
+
89
+ args.with_defaults(:version => version[:filename])
90
+
91
+ Sequel::Migrator.run(Sequel::Model.db, "db/migrate", :target => args[:version].to_i)
92
+ Rake::Task['db:version'].execute
93
+ end
94
+
95
+ desc "Perform migration reset (full rollback and migration)"
96
+ task :reset => :environment do
97
+ Sequel.extension :migration
98
+
99
+ Sequel::Model.db.loggers = [Logger.new($stdout)]
100
+
101
+ Sequel::Migrator.run(Sequel::Model.db, "db/migrate", :target => 0)
102
+ Sequel::Migrator.run(Sequel::Model.db, "db/migrate")
103
+ Rake::Task['db:version'].execute
104
+ end
105
+ end
@@ -0,0 +1,21 @@
1
+ namespace :g do
2
+ desc "Create migration"
3
+ task :migration, [:name] do |t, args|
4
+ if args[:name].nil?
5
+ raise "Please provide a name for migration (rake 'g:migration[my_file_name]')"
6
+ end
7
+
8
+ date_part = Time.now.strftime("%Y%m%d%H%M%S")
9
+ words_part = args[:name].to_s.split(/(?=[A-Z])/).map(&:downcase).join("_")
10
+ filename = "#{date_part}_#{words_part}.rb"
11
+
12
+ full_filename = File.join("db", "migrate", filename)
13
+
14
+ File.open(full_filename, "w") do |file|
15
+ file.puts("Sequel.migration do")
16
+ file.puts(" change do")
17
+ file.puts(" end")
18
+ file.puts("end")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sequel/migrate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sequel-migrate"
8
+ spec.version = Sequel::Migrate::VERSION
9
+ spec.authors = ["Teodor"]
10
+ spec.email = ["teodor.pripoae@gmail.com"]
11
+
12
+ spec.summary = %q{Migrate sequel databases}
13
+ spec.description = %q{Migrate sequel databases}
14
+ spec.homepage = "https://github.com/teodor-pripoae/sequel-migrate"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features|bin/console|bin/setup)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.platform = 'java'
24
+ spec.add_runtime_dependency 'rake', '~> 10.0'
25
+ spec.add_runtime_dependency 'pry', '>= 0.10.4', '< 1.0'
26
+ spec.add_runtime_dependency 'sequel', '>= 4.43.0', '< 5.0'
27
+ spec.add_runtime_dependency 'jdbc-mysql', ">= 5.1.40", "< 6.0"
28
+ spec.add_runtime_dependency 'activesupport', ">= 5.0.1", "< 5.1"
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.13"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ end
metadata ADDED
@@ -0,0 +1,180 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sequel-migrate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: java
6
+ authors:
7
+ - Teodor
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '10.0'
19
+ name: rake
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.10.4
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.0'
36
+ name: pry
37
+ prerelease: false
38
+ type: :runtime
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.10.4
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 4.43.0
53
+ - - "<"
54
+ - !ruby/object:Gem::Version
55
+ version: '5.0'
56
+ name: sequel
57
+ prerelease: false
58
+ type: :runtime
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 4.43.0
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '5.0'
67
+ - !ruby/object:Gem::Dependency
68
+ requirement: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 5.1.40
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '6.0'
76
+ name: jdbc-mysql
77
+ prerelease: false
78
+ type: :runtime
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 5.1.40
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: '6.0'
87
+ - !ruby/object:Gem::Dependency
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 5.0.1
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: '5.1'
96
+ name: activesupport
97
+ prerelease: false
98
+ type: :runtime
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 5.0.1
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: '5.1'
107
+ - !ruby/object:Gem::Dependency
108
+ requirement: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1.13'
113
+ name: bundler
114
+ prerelease: false
115
+ type: :development
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '1.13'
121
+ - !ruby/object:Gem::Dependency
122
+ requirement: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '3.0'
127
+ name: rspec
128
+ prerelease: false
129
+ type: :development
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: '3.0'
135
+ description: Migrate sequel databases
136
+ email:
137
+ - teodor.pripoae@gmail.com
138
+ executables: []
139
+ extensions: []
140
+ extra_rdoc_files: []
141
+ files:
142
+ - ".gitignore"
143
+ - ".rspec"
144
+ - ".ruby-version"
145
+ - ".travis.yml"
146
+ - Gemfile
147
+ - README.md
148
+ - Rakefile
149
+ - bin/console
150
+ - bin/setup
151
+ - bin/sm
152
+ - lib/sequel/migrate.rb
153
+ - lib/sequel/migrate/version.rb
154
+ - lib/tasks/db.rake
155
+ - lib/tasks/generate.rake
156
+ - sequel-migrate.gemspec
157
+ homepage: https://github.com/teodor-pripoae/sequel-migrate
158
+ licenses: []
159
+ metadata: {}
160
+ post_install_message:
161
+ rdoc_options: []
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubyforge_project:
176
+ rubygems_version: 2.6.8
177
+ signing_key:
178
+ specification_version: 4
179
+ summary: Migrate sequel databases
180
+ test_files: []