sequelize-rails 0.5.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffb36f44727f56d3d9f157d95b669785999567afc37d7b2b4a1c99e4b7fbfe40
4
- data.tar.gz: f2f9b2e5b1a96a8048731ab03cbc279fb363f1549da47f988869dc9d55d34989
3
+ metadata.gz: ed358e5bb7080bb8fe4c713a46b295cb7cd1c51de02cda2b6daf0580e2ae42be
4
+ data.tar.gz: 8382be25407a695811c735ca4bf93e4eddf709cc86bb9d501b948f2bfb090ec2
5
5
  SHA512:
6
- metadata.gz: 33451f66a4c01399910e6ec4bfdbed2a9136f1da5fe537020efae31a39e1cbdc514da3f7f0773888cf16bd4e5a1648ef57d76170fd3ee76aa006e27fde85485a
7
- data.tar.gz: 692a29096179817f411539a22363cf4a8688bdf688236fa9c5ecee2b8644c0a72d78939be12db570ff6a5faa7a9d620fd90415b5ea075a2107d283f85f4f06de
6
+ metadata.gz: f940cf5b229febd629e5a06ecf9d7c69cfb5a6e0ca36ede15bdcbebd3e836ea919b83eb8d20e9658d2a4339d26e3663684aab0781c20657a564a99d4ad9935e1
7
+ data.tar.gz: b9fea39afcb85fe6bfd7659e470f676b1df28e49355a90598f9e3a10fdf4011686c7d200f8e73790282a9de09839d92dc8afd95f75684090db168345eaa3d348
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.1] - 2023-09-04
4
+
5
+ - Migrations now generate SQL files by default
6
+
7
+ ## [0.6.0] - 2023-09-04
8
+
9
+ - Adds migration generator
10
+
3
11
  ## [0.5.0] - 2023-09-04
4
12
 
5
13
  - Adds the `db:seed` rake task for running seed files
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sequelize-rails (0.5.0)
4
+ sequelize-rails (0.6.1)
5
5
  activerecord (>= 6.0.0)
6
6
  rails (>= 6.0.0)
7
7
  sequel (>= 5.0.0)
@@ -9,67 +9,67 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actioncable (7.0.7)
13
- actionpack (= 7.0.7)
14
- activesupport (= 7.0.7)
12
+ actioncable (7.0.7.2)
13
+ actionpack (= 7.0.7.2)
14
+ activesupport (= 7.0.7.2)
15
15
  nio4r (~> 2.0)
16
16
  websocket-driver (>= 0.6.1)
17
- actionmailbox (7.0.7)
18
- actionpack (= 7.0.7)
19
- activejob (= 7.0.7)
20
- activerecord (= 7.0.7)
21
- activestorage (= 7.0.7)
22
- activesupport (= 7.0.7)
17
+ actionmailbox (7.0.7.2)
18
+ actionpack (= 7.0.7.2)
19
+ activejob (= 7.0.7.2)
20
+ activerecord (= 7.0.7.2)
21
+ activestorage (= 7.0.7.2)
22
+ activesupport (= 7.0.7.2)
23
23
  mail (>= 2.7.1)
24
24
  net-imap
25
25
  net-pop
26
26
  net-smtp
27
- actionmailer (7.0.7)
28
- actionpack (= 7.0.7)
29
- actionview (= 7.0.7)
30
- activejob (= 7.0.7)
31
- activesupport (= 7.0.7)
27
+ actionmailer (7.0.7.2)
28
+ actionpack (= 7.0.7.2)
29
+ actionview (= 7.0.7.2)
30
+ activejob (= 7.0.7.2)
31
+ activesupport (= 7.0.7.2)
32
32
  mail (~> 2.5, >= 2.5.4)
33
33
  net-imap
34
34
  net-pop
35
35
  net-smtp
36
36
  rails-dom-testing (~> 2.0)
37
- actionpack (7.0.7)
38
- actionview (= 7.0.7)
39
- activesupport (= 7.0.7)
37
+ actionpack (7.0.7.2)
38
+ actionview (= 7.0.7.2)
39
+ activesupport (= 7.0.7.2)
40
40
  rack (~> 2.0, >= 2.2.4)
41
41
  rack-test (>= 0.6.3)
42
42
  rails-dom-testing (~> 2.0)
43
43
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
44
- actiontext (7.0.7)
45
- actionpack (= 7.0.7)
46
- activerecord (= 7.0.7)
47
- activestorage (= 7.0.7)
48
- activesupport (= 7.0.7)
44
+ actiontext (7.0.7.2)
45
+ actionpack (= 7.0.7.2)
46
+ activerecord (= 7.0.7.2)
47
+ activestorage (= 7.0.7.2)
48
+ activesupport (= 7.0.7.2)
49
49
  globalid (>= 0.6.0)
50
50
  nokogiri (>= 1.8.5)
51
- actionview (7.0.7)
52
- activesupport (= 7.0.7)
51
+ actionview (7.0.7.2)
52
+ activesupport (= 7.0.7.2)
53
53
  builder (~> 3.1)
54
54
  erubi (~> 1.4)
55
55
  rails-dom-testing (~> 2.0)
56
56
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
57
- activejob (7.0.7)
58
- activesupport (= 7.0.7)
57
+ activejob (7.0.7.2)
58
+ activesupport (= 7.0.7.2)
59
59
  globalid (>= 0.3.6)
60
- activemodel (7.0.7)
61
- activesupport (= 7.0.7)
62
- activerecord (7.0.7)
63
- activemodel (= 7.0.7)
64
- activesupport (= 7.0.7)
65
- activestorage (7.0.7)
66
- actionpack (= 7.0.7)
67
- activejob (= 7.0.7)
68
- activerecord (= 7.0.7)
69
- activesupport (= 7.0.7)
60
+ activemodel (7.0.7.2)
61
+ activesupport (= 7.0.7.2)
62
+ activerecord (7.0.7.2)
63
+ activemodel (= 7.0.7.2)
64
+ activesupport (= 7.0.7.2)
65
+ activestorage (7.0.7.2)
66
+ actionpack (= 7.0.7.2)
67
+ activejob (= 7.0.7.2)
68
+ activerecord (= 7.0.7.2)
69
+ activesupport (= 7.0.7.2)
70
70
  marcel (~> 1.0)
71
71
  mini_mime (>= 1.1.0)
72
- activesupport (7.0.7)
72
+ activesupport (7.0.7.2)
73
73
  concurrent-ruby (~> 1.0, >= 1.0.2)
74
74
  i18n (>= 1.6, < 2)
75
75
  minitest (>= 5.1)
@@ -80,14 +80,15 @@ GEM
80
80
  rake
81
81
  thor (>= 0.14.0)
82
82
  ast (2.4.2)
83
+ bigdecimal (3.1.4)
83
84
  builder (3.2.4)
84
85
  coderay (1.1.3)
85
86
  concurrent-ruby (1.2.2)
86
87
  crass (1.0.6)
87
88
  date (3.3.3)
88
89
  erubi (1.12.0)
89
- globalid (1.1.0)
90
- activesupport (>= 5.0)
90
+ globalid (1.2.0)
91
+ activesupport (>= 6.1)
91
92
  i18n (1.14.1)
92
93
  concurrent-ruby (~> 1.0)
93
94
  json (2.6.3)
@@ -133,20 +134,20 @@ GEM
133
134
  rack (2.2.8)
134
135
  rack-test (2.1.0)
135
136
  rack (>= 1.3)
136
- rails (7.0.7)
137
- actioncable (= 7.0.7)
138
- actionmailbox (= 7.0.7)
139
- actionmailer (= 7.0.7)
140
- actionpack (= 7.0.7)
141
- actiontext (= 7.0.7)
142
- actionview (= 7.0.7)
143
- activejob (= 7.0.7)
144
- activemodel (= 7.0.7)
145
- activerecord (= 7.0.7)
146
- activestorage (= 7.0.7)
147
- activesupport (= 7.0.7)
137
+ rails (7.0.7.2)
138
+ actioncable (= 7.0.7.2)
139
+ actionmailbox (= 7.0.7.2)
140
+ actionmailer (= 7.0.7.2)
141
+ actionpack (= 7.0.7.2)
142
+ actiontext (= 7.0.7.2)
143
+ actionview (= 7.0.7.2)
144
+ activejob (= 7.0.7.2)
145
+ activemodel (= 7.0.7.2)
146
+ activerecord (= 7.0.7.2)
147
+ activestorage (= 7.0.7.2)
148
+ activesupport (= 7.0.7.2)
148
149
  bundler (>= 1.15.0)
149
- railties (= 7.0.7)
150
+ railties (= 7.0.7.2)
150
151
  rails-dom-testing (2.2.0)
151
152
  activesupport (>= 5.0.0)
152
153
  minitest
@@ -154,9 +155,9 @@ GEM
154
155
  rails-html-sanitizer (1.6.0)
155
156
  loofah (~> 2.21)
156
157
  nokogiri (~> 1.14)
157
- railties (7.0.7)
158
- actionpack (= 7.0.7)
159
- activesupport (= 7.0.7)
158
+ railties (7.0.7.2)
159
+ actionpack (= 7.0.7.2)
160
+ activesupport (= 7.0.7.2)
160
161
  method_source
161
162
  rake (>= 12.2)
162
163
  thor (~> 1.0)
@@ -181,7 +182,8 @@ GEM
181
182
  rubocop (>= 1.7.0, < 2.0)
182
183
  rubocop-ast (>= 0.4.0)
183
184
  ruby-progressbar (1.13.0)
184
- sequel (5.71.0)
185
+ sequel (5.72.0)
186
+ bigdecimal
185
187
  sqlite3 (1.6.1)
186
188
  mini_portile2 (~> 2.8.0)
187
189
  standard (1.25.3)
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sequel
4
+ module Generators
5
+ class ApplicationRecordGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ def create_application_record
9
+ template "application_record.rb", application_record_file_name
10
+ end
11
+
12
+ private
13
+
14
+ def application_record_file_name
15
+ @application_record_file_name ||=
16
+ if namespaced?
17
+ "app/models/#{namespaced_path}/application_record.rb"
18
+ else
19
+ "app/models/application_record.rb"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sequel
4
+ module Generators
5
+ class MigrationGenerator < ::Rails::Generators::NamedBase
6
+ include ::Rails::Generators::Migration
7
+
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
11
+
12
+ def self.next_migration_number _dirname
13
+ Time.now.strftime "%Y%m%d%H%M%S"
14
+ end
15
+
16
+ def create_migration_file
17
+ migration_template "migration.rb.erb", "db/migrate/#{file_name}.rb"
18
+ migration_template "up.sql.erb", "db/migrate/#{file_name}_up.sql"
19
+ migration_template "down.sql.erb", "db/migrate/#{file_name}_down.sql"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sequel
4
+ module Generators
5
+ class ModelGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("templates", __dir__)
7
+ end
8
+ end
9
+ end
@@ -4,7 +4,7 @@ class ApplicationRecord < Sequel::Model
4
4
  dataset = nil
5
5
  end
6
6
 
7
- # Allows subclassed models to be initialzed with a customized dataset
7
+ # Allows subclassed models to be initialized with a customized dataset
8
8
  def ApplicationRecord *args
9
9
  ApplicationRecord.Model *args
10
10
  end
@@ -0,0 +1 @@
1
+ -- Write rollback migration here
@@ -0,0 +1,13 @@
1
+ Sequel.migration do
2
+ up do
3
+ transaction do
4
+ run File.read(File.join(File.dirname(__FILE__), "#{File.basename(__FILE__, ".rb")}_up.sql"))
5
+ end
6
+ end
7
+
8
+ down do
9
+ transaction do
10
+ run File.read(File.join(File.dirname(__FILE__), "#{File.basename(__FILE__, ".rb")}_down.sql"))
11
+ end
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ -- Write forwards migration here
@@ -24,7 +24,7 @@ module Sequel
24
24
  ::Sequel::Rails::Railties::LogSubscriber.backtrace_cleaner.add_filter { |line| line.gsub(::Rails.root.to_s + File::SEPARATOR, "") }
25
25
 
26
26
  # Config initialization
27
- config.app_generators.orm :sequelize_rails, migration: :sequel_migration
27
+ config.app_generators.orm :sequel
28
28
  config.sequel = ActiveSupport::OrderedOptions.new
29
29
 
30
30
  initializer "sequel.plugins" do
@@ -64,6 +64,12 @@ module Sequel
64
64
  rake_tasks do
65
65
  load File.expand_path("../tasks.rake", __dir__)
66
66
  end
67
+
68
+ generators do
69
+ require "sequel/generators/application_record_generator"
70
+ require "sequel/generators/migration_generator"
71
+ require "sequel/generators/model_generator"
72
+ end
67
73
  end
68
74
  end
69
75
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sequel
4
4
  module Rails
5
- VERSION = "0.5.0"
5
+ VERSION = "0.6.1"
6
6
  end
7
7
  end
data/lib/sequel/rails.rb CHANGED
@@ -7,12 +7,6 @@ require "sequel/rails/translation_support"
7
7
  # Plugins
8
8
  require "sequel/plugins/pretty_print"
9
9
 
10
- # Generators
11
- require "rails/generators"
12
- require "sequel/rails/generators/migration/migration_generator"
13
- require "sequel/rails/generators/model/model_generator"
14
- require "sequel/rails/generators/application_record/application_record_generator"
15
-
16
10
  # Minitest support
17
11
  begin
18
12
  gem "minitest"
@@ -141,7 +141,17 @@ db_namespace = namespace ns do
141
141
  end
142
142
 
143
143
  desc "Rolls back the last migration and re-runs it"
144
- task redo: [:down, :up]
144
+ task redo: [:connection] do
145
+ # down
146
+ target = (migrator.applied_migrations[-2] || "0_").split("_", 2).first.to_i
147
+ migrator(target: target).run
148
+ # up
149
+ pending = migrator.migration_tuples.first
150
+ if pending
151
+ target = pending[1].split("_", 2).first.to_i
152
+ migrator(target: target).run
153
+ end
154
+ end
145
155
 
146
156
  desc "Displays the status of the database migrations"
147
157
  task status: [:connection] do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequelize-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenaniah Cerny
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -161,14 +161,16 @@ files:
161
161
  - gemfiles/rails_6.gemfile
162
162
  - gemfiles/rails_7.gemfile
163
163
  - lib/sequel/extensions/sequel_instrumentation.rb
164
+ - lib/sequel/generators/application_record_generator.rb
165
+ - lib/sequel/generators/migration_generator.rb
166
+ - lib/sequel/generators/model_generator.rb
167
+ - lib/sequel/generators/templates/application_record.rb.tt
168
+ - lib/sequel/generators/templates/down.sql.erb
169
+ - lib/sequel/generators/templates/migration.rb.erb
170
+ - lib/sequel/generators/templates/up.sql.erb
164
171
  - lib/sequel/plugins/pretty_print.rb
165
172
  - lib/sequel/rails.rb
166
173
  - lib/sequel/rails/db_console.rb
167
- - lib/sequel/rails/generators/application_record/application_record_generator.rb
168
- - lib/sequel/rails/generators/application_record/templates/application_record.rb.tt
169
- - lib/sequel/rails/generators/migration/migration_generator.rb
170
- - lib/sequel/rails/generators/migration/templates/migration.rb.erb
171
- - lib/sequel/rails/generators/model/model_generator.rb
172
174
  - lib/sequel/rails/minitest.rb
173
175
  - lib/sequel/rails/railtie.rb
174
176
  - lib/sequel/rails/railties/controller_runtime.rb
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sequel
4
- module Rails
5
- module Generators
6
- class ApplicationRecordGenerator < ::Rails::Generators::Base
7
- source_root File.expand_path("templates", __dir__)
8
-
9
- def create_application_record
10
- template "application_record.rb", application_record_file_name
11
- end
12
-
13
- private
14
-
15
- def application_record_file_name
16
- @application_record_file_name ||=
17
- if namespaced?
18
- "app/models/#{namespaced_path}/application_record.rb"
19
- else
20
- "app/models/application_record.rb"
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sequel
4
- module Rails
5
- module Generators
6
- class MigrationGenerator < ::Rails::Generators::NamedBase
7
- include ::Rails::Generators::Migration
8
-
9
- source_root File.expand_path("templates", __dir__)
10
-
11
- argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
12
-
13
- def self.next_migration_number _dirname
14
- Time.now.strftime "%Y%m%d%H%M%S"
15
- end
16
-
17
- def create_migration_file
18
- migration_template "migration.rb.erb", "db/migrate/#{file_name}.rb"
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,9 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- # Add forward migration code here
4
- end
5
-
6
- down do
7
- # Add rollback migration code here
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sequel
4
- module Rails
5
- module Generators
6
- class ModelGenerator < ::Rails::Generators::NamedBase
7
- source_root File.expand_path("templates", __dir__)
8
- end
9
- end
10
- end
11
- end