Giter Site home page Giter Site logo

active_record_migrations's People

Contributors

afoster avatar bitdeli-chef avatar collin avatar rosenfeld avatar schm avatar swaroopmurthy avatar viddo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

active_record_migrations's Issues

Support for DATABASE_URL

I find using the DATABASE_URL environment variable handy in some cases. It would be great if this library could add support for it instead of YAML config in the Rails style of config/database.yml.

Circular dependency detected: TOP => db:create => db:load_config => environment => db:load_config

I'm trying to upgrade one of our Grape API apps with ActiveRecord 5.2 where we also use ActiveRecord Migrations. Now, we're getting the following error

# rake db:create
rake aborted!
Circular dependency detected: TOP => db:create => db:load_config => environment => db:load_config
/usr/local/bundle/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:create => db:load_config => environment
(See full trace by running task with --trace)

request for 4.1.11.1 release

Hi There,

Rails 4.1.11 just was released. Just wondering how long before you have a chance to release new versions.

Thanks.

"Minor issue" regarding table ar_internal_metadata with release 6.1.1.1

Just point out a "minor issue" with release 6.1.1.1 or maybe just me OCD.
When I ran this rake task db=production rake db:migrate it did migrate for production database however in table 'ar_internal_metadata' it set 'enviroment' value to 'development'. That is due to missing rails env variable eg: RAILS_ENV=production

Currently my work around is creating ActiveRecordMigrations configure with following code

ActiveRecordMigrations.configure do |c|
  c.schema_format = :sql # default is :ruby
  # make sure table ar_internal_metadata would contain same environment information
  Rails.env = ENV['db'] || Rails.env
end

NoMethodError: undefined method `migrate' for ActiveRecord::Migrator:Class

here is Rakefile

require "active_record_migrations"
require "active_support"
require "active_record"

namespace :db do
  desc "Migrate the database"

  task(:migrate => :environment) do
    ActiveRecord::Base.logger = Logger.new(STDOUT)
    ActiveRecord::Migration.verbose = true
    ActiveRecord::Migrator.migrate "db/migrate"
  end

  task(:environment) do
    ActiveRecordMigrations.configure do |c|
      c.database_configuration = {
        "development" => { "adapter" => "sqlite3", "database" => "db/custom.sqlite3" },
      }

      c.schema_format = :sql # default is :ruby
    end
  end
end

rake db:migrate

rake aborted!
NoMethodError: undefined method migrate' for ActiveRecord::Migrator:Class /rbapp/sinatra/ar/Rakefile:14:in block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Render-related gems should not be dependencies

I'm not sure why this gem is requiring the following gems:

  • rails-deprecated-sanitizer
  • rails-dom-testing
  • rails-html-sanitizer
  • actionview

I can't imagine why a migrations gem would need these. Even the necessity for railties is questionable, since ActiveRecord should be the only "railtie".

I wanted to use this gem because I wanted ActiveRecord migrations without the overhead that Rails adds, but upon discovering this extra Rails baggage I won't use it. I suspect that there are others who would use this gem for the same reasons. It looks like a nice gem, otherwise. Consider removing the dependencies I listed.

NoMethodError: undefined method `root' for Rails:Module

I'm building a gem for internal company use. The gem needs to create migrations, but doesn't need to run them, except maybe for tests. I have a number of projects which depend on the gem. I tried to create a sample migration to see what gets generated, but I got an error (stack trace below).

I thought this gem replicated ActiveRecord Rake tasks so one could use ActiveRecord without Rails. After getting the error, I search through ActiveRecordMigrations' source code and found two references to Rails.root:

See

DatabaseTasks.root = Rails.root

See
Rails::Generators.invoke "active_record_migrations:migration", params,
behavior: :invoke, destination_root: Rails.root

The only thing I need ActiveRecordMigrations for in my internal gem is to create migrations. Should I just roll my own generator, or is Rails mistakenly being used here?

$ bundle exec rake db:new_migration\[add_foo_to_bars\] --trace
** Invoke db:new_migration (first_time)
** Execute db:new_migration
rake aborted!
NoMethodError: undefined method `root' for Rails:Module
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/active_record_migrations-5.0.0.2/lib/active_record_migrations/tasks/new_migration.rake:31:in `block (2 levels) in <top (required)>'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/usr/local/opt/rbenv/versions/2.3.1/bin/rake:23:in `load'
/usr/local/opt/rbenv/versions/2.3.1/bin/rake:23:in `<top (required)>'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
/usr/local/opt/rbenv/versions/2.3.1/bin/bundle:23:in `load'
/usr/local/opt/rbenv/versions/2.3.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:new_migration

Package gem with active_record_migrations

Hi,

this is probably more a StackOverflow question, if so, just give me a hint and close this issue.

I want to create a gem (call it ar_models) that contains some ActiveRecord-models and provides the means to setup and migrate the database. Then, other gems or projects can require that gem, run e.g. a rake Task to setup (or migrate) the database and happily use the model. (I am not talking about rails projects here).

Now, in active_record_migrations the migration files are picked up from db/migrate (although it can be changed in the options). Either I know the absolute path to the "installed" gem (ar_models) or I copy over the migration files. Is there a cleaner option that I do not see? As is, it renders the otherwise great active_record_migrations gem a bit useless for my purpose.

I.e. I want the "other gem" (call it ar_model_user) to be able to define database location and stuff, but not be concerned with the migration details.

Thanks for contributing, reading and responding.

Deprecation warning with AR 7

I get the following deprecation warning after upgrading to AR 7 from AR 6:

DEPRECATION WARNING: ActiveRecord::Base.schema_format= is deprecated and will be removed in Rails 7.1.
Use `ActiveRecord.schema_format=` instead.
 (called from <top (required)> at /home/ded/src/byr/Rakefile:46)

Looks like a simple fix.

Not loading Foreigner

I was trying to use the Foreigner gem, and included it in the Gemspec, but it seems to not be loading.

The only way I could get it working is by including the following at the top of the migration:

require "foreigner"

ActiveSupport.on_load :active_record do
  Foreigner.load
end

This doesn't seem like the right way to go, as foreigner supports extending other migration tasks. Are the gemspec gems actually being loaded?

Don't use require_relative in active_record_migrations.rb

In our staging environment, it causes the ActiveRecordMigrations.load_tasks call to re-evaluate configurations.rb and thus revert to the default configuration (so loading of the Rakefile fails with something like "db/config.yml not found").

IIUC, because tasks/new_migration.rake has require 'active_record_migrations/configurations', and load_tasks loads that file.

For some reason, that doesn't happen on my (development) machine, but mixing require and require_relative is bad either way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.