A Ruby On Rails-like migration tool - ruby-on-rails

I like that Ruby On Rails allows you to write a simple schema in which you can create and update a database using. Is there any tool like Ruby On Rails's migration, as I would like to use the method without using Ruby On Rails for my website development?

There's no reason you can't use ActiveRecord::Migration outside of a rails app. In fact, you'll find plenty of examples of people doing this, as in http://exposinggotchas.blogspot.com/2011/02/activerecord-migrations-without-rails.html
If you're using mongo as the persistent store, check out mongrations for this.

I have heard this week on a little conference a talk about a tool called Liquibase, a database change management tool. It is based on Java (I think), but manages the database migrations in an XML file. The change sets you have to write are similar to the migrations you can write with Rails. If you use Liquibase inside an IDE like Eclipse, you get completion for all relevant parts of the change sets. It supports a lot of databases out of the box, so it could be an alternative, especially that nowadays Java is installed everywhere.

I recommend Python Alembic. It's not Ruby though.

Related

Is there a straight-forward way of doing an ORM roundtrip workflow in Grails 3+?

For the last few years I have been a Symfony developer and one of the things I enjoy the most is the fact that I don't have to write/maintain entities by hand.
Through Doctrine (the integrated ORM) I can extract the table metadata and relations through
php app/console doctrine:mapping:import SomeBundle yaml
And then I can generate the ORM entity classes
php app/console generate:doctrine:entities SomeBundle
And I'm friggin' done.
Need to migrate?, no problem. Use this command to create a migration:
doctrine:migrations:diff
And the following to migrate to it:
doctrine:migrations:migrate
For Grails, it seems that there is no straight forward way, unless I go and download the Hibernate tools and a tool like Liquibase.
There seem to be a couple of plugins that did this, but the one for reverse engineering from a database does not seem supported for Grails 3 (db-reverse-engineer) and the one for migrations I tried, but does not seem stable enough (database-migration).
Am I just looking in the wrong place?, if not, how do you as a professional Grails developer solve these needs?
No there is not a straight forward way to make a "round-trip" as you describe in Grails 3.x.
Most plugins aren't going to be 3.x ready yet. 3.x is still quite new.
That said, the reverse engineering plugin isn't designed to be a fully automated one-shot handles everything type of plugin. It's suppose to be a running start that you take the last bit by hand.
The migration plugin on the other hand is fully production ready and very stable in 2.x.

Best alternative for data fixes in rails?

When a rails project grows a lot, you can find yourself having trouble with fixes for the data in the production database.
I have normally used migrations or specific rake tasks for this, but I was wondering if a system similar to migrations existed for keeping the database fixes and run them when needed.
I know you probably figured this out by now but there IS a gem for this... it is called datafix
https://github.com/Casecommons/datafix
basically you create a datafix, like a migration, and a spec for it, then you can run it as needed on the server.
The following gems can be also used for this purpose:
nondestructive_migrations
datafix
migrake
migration-data
data-migrate
I prefer nondestructive_migrations and datafix they are very similar - nondestructive_migrations simpler implementation building on rails migrations.

Compiling / building ruby online from a working rails application

I'm totally new to Ruby but not to programming. All I did was going through try ruby and reading differences from other few languages I know better (mostly PHP and some Python). So I have no idea how Rails differ from Ruby and maybe this is an absurd question.
Anyways...
I don't want (or am able) to install Ruby on my machine and I'd still like to build a single working source file. Is it possible to have an online compiler of some sort? If so, how?
If I write a Rails web site (comprised of either one or many files) using any given host (that far I know I can), would I be able to use that same code with very minor modifications and just run as a Ruby app? Again, how?
(new) What about the other way around: a Ruby app turning into a Rails web page? Easy to do?
I really hope for a "yes" on them all, but I doubt on the 1st and not so much on the last. :)
There are online "IDEs" you can use to try out ruby:
http://ideone.com
http://codepad.org
But mind you that Ruby on Rails is a framework written in Ruby and those sites don't have RoR installed. Also note you that a Rails app has many, many files.
If you have the same code and same server configuration (version of ruby, database, plugins, etc.) you should only need minor modifications to the config file.
Ruby on Rails is on Ruby. So whatever works on Ruby should work just fine on RoR with minor modifications. However, you'll probably want to rewrite the app to take advantage of many of the features RoR provides.

A tool to automatically generate a UML diagram for a Rails Application

Looking for a good tool/gem that can automatically generate a nice looking UML diagram for an existing rails application.
(Im imagining such a tool would read the schema.rb file and then scan the models for relationships)
For Rails 3, try Railroady, it's maintained as well.
You could try Rails ERD as a an alternative to Railroad. It is maintained and works specifically for Rails 3.
RubyMine has a tool to do this; they call it a "model dependency diagram", but it generates a UML-like graph for your application models.
If you don't want to use RubyMine, check out RailRoad. It's a standalone tool that does similar, though RubyMine's is prettier, IMO.

Is Ruby on Rails suitable for a non-web application?

I am interested in developing a workstation-based application that communicates with a proprietary data server and that presents information from that server to the user. I am not intending the user interface to be browser-based, and have been considering Qt as my framework. Should I consider RoR for this? Thanks.
Rails is specifically a web application framework, however there are GUI toolkits that can be used with Ruby, including Qt (although not the open source version).
Rails is a web framework, so you should not use it. However, you should absolutely consider using Ruby. I've never used Ruby with Qt, but I've had a lot of success using JRuby with Swing. I use the Profligacy gem, which suits my needs quite well.
Being a web framework you may not use rails, but you may certainly use some parts of rails.
For example just use require 'active_record' and you instantly have access to AR and all its magic - validations, belongs_to, has_many and other similar associations.
You can use the ActiveRecord part of Ruby on Rails, which for a long time was the most interesting part of RoR. https://edgeguides.rubyonrails.org/active_record_basics.html
Alternatively, use another Ruby ORM, like DataMapper: http://datamapper.org/
The answer is yes. I've been working on a project, Qt on Rails, which combines Qt with a Rails back end. The end result is that you can develop your Qt app's in Ruby, harness the libraries of Rails and there's support for scaffolding of apps as well.
It’s still a 'Work In Progress' but the current latest version at the Qt on Rails github repository (http://github.com/theirishpenguin/qtonrails) will certainly give a flavour of where the project is headed. Contributors and feedback is most welcome and detailed blog post is available on the project.

Resources