This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 97643 - Cannot run migrations inside IDE
Summary: Cannot run migrations inside IDE
Status: RESOLVED FIXED
Alias: None
Product: ruby
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Torbjorn Norbye
URL:
Keywords:
: 97592 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-03-12 00:57 UTC by Craig Mcclanahan
Modified: 2007-07-03 14:43 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Migrate Database Error Output (18.46 KB, text/plain)
2007-03-30 15:30 UTC, William Leonard
Details
Sample Project with Migrations for Testing (84.77 KB, application/octet-stream)
2007-03-30 15:31 UTC, William Leonard
Details
Screen shot showing 2 migrations but only 1 entry in the Migrate Database menu (15.97 KB, image/png)
2007-04-26 14:44 UTC, William Leonard
Details
"Migrate Database / To Version xx" not showing versions correctly (in a fresh new Rails project) (44.15 KB, image/jpeg)
2007-05-24 22:34 UTC, demisone
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Mcclanahan 2007-03-12 00:57:51 UTC
(Using hudson ruby build 363, native RoR 1.2.2, on Solaris)

I can generate a database migration using the "Generate ..." menu option, but
attempting to run it inside the IDE fails.  I tried like this:

* Open "Database Migrations" and "migrate" in the project menu

* Select the migration I want to run

* Select menu option Run -> Run File -> Run 001_xxxxx.rb
  (RFE ... this should be possible from a context menu
  on the migration node itself)

On the status line you see "Server Startup" for a while, then "Cannot start
server".  However, both WEBrick and MySQL are already running.
Comment 1 Craig Mcclanahan 2007-03-12 01:06:17 UTC
Of course, migrations run under rake, so this depends on resolving 67592 (make
it possible to run rake inside the tool) first.
Comment 2 Craig Mcclanahan 2007-03-12 01:07:38 UTC
Of course, migrations run under rake, so this depends on resolving 97592 (make
it possible to run rake inside the tool) first.
Comment 3 Torbjorn Norbye 2007-03-12 22:42:56 UTC
I think the root problem here is difficulty with I/O from the native Ruby
process.  This happens just executing simple Ruby programs using native Ruby as
well. I've narrowed it down, and basically, the output stream I get from the
Ruby process tells me there is no pending output (.available() returns 0) even
when there definitely is output from the process. I'm going to contact somebody
in JDK land about this.
Comment 4 Torbjorn Norbye 2007-03-20 02:42:30 UTC
*** Issue 97592 has been marked as a duplicate of this issue. ***
Comment 5 Torbjorn Norbye 2007-03-20 02:45:21 UTC
I've added a "Rake Migrations" context menu item to the Rails project type (which runs rake migrate), 
but I think we need more here.

Here's what I'm thinking so far:

* "Rake Migration" on the project node runs rake migrate - e.g. migrates to the current version. Ditto 
for the "Rake Migrations" node in the project's logical view.
* On each of the ruby files under the "Rake Migrations" logical node in the Rails project, have a context 
menu to run the migrations to that particular migration level.
* On the project node, add a "Rake" pullright menu which lists all the rake targets - possibly with 
prebuilt/hardcoded common targets first, then dynamically add targets scanned from the rakefiles. 
(This second part will be a bit tricky since Rakefiles consist of dynamic Ruby code, not static 
declarations like most ant files.)

Any other aspects of this issue or other UI ideas?
Comment 6 Torbjorn Norbye 2007-03-27 02:33:53 UTC
This should be fixed now; there's a special "Migrate Database" context menu action on Rails projects 
which lets you migrate to the current level, or any of the specific versions that you have migrations files 
for. 

While editing a migration file, you can also Shift-F6 (Run File) it to run rake migrations to its specific 
version.
Comment 7 William Leonard 2007-03-30 15:29:22 UTC
Hi Tor,

This isn't completely working yet (at least on Windows). 

Run Rake Target > db > mirgrate works.

However, Migrate Database fails. It appears to be trying to run a test and
therefore using my test configuration. It also appears to have some problems
with the spaces in the directory name.

(in D:/MyDocuments/Temp/Temp/BlogDemo)
C:/Documents and Settings/Brian Leonard/.netbeans/dev/jruby-0.9.8/bin/jruby.bat
-Ilib;test "C:/Documents and Settings/Brian
Leonard/.netbeans/dev/jruby-0.9.8/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake/rake_test_loader.rb"
"test/functional/blog_controller_test.rb" 
'C:\Documents' is not recognized as an internal or external command,

operable program or batch file.

C:/Documents and Settings/Brian Leonard/.netbeans/dev/jruby-0.9.8/bin/jruby.bat
-Ilib;test "C:/Documents and Settings/Brian
Leonard/.netbeans/dev/jruby-0.9.8/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake/rake_test_loader.rb"
 
'C:\Documents' is not recognized as an internal or external command,

operable program or batch file.

database configuration specifies nonexistent mysql adapter
C:/Documents and Settings/Brian
Leonard/.netbeans/dev/jruby-0.9.8/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:209:in
`establish_connection'

The rest of the output's pretty log, so I'll attach it.

Also, you mention the ability to migrate to the current level, or any of the
specific versions that I have migrations files for. I don't see this to be
available either. 

I'm attaching a sample project that has 2 migration files: one that creates a
table and a second that adds a column. Runing Run Rake Target > db > mirgrate
works fine. But how to I just run 002_add_column.rb? Using Shift+F6 gives a
different error (probably related to Windows):

(in D:/MyDocuments/Temp/Temp/BlogDemo/db/migrate)
rake aborted!
uninitialized constant ActiveRecord
C:/Documents and Settings/Brian
Leonard/.netbeans/dev/jruby-0.9.8/lib/ruby/gems/1.8/gems/rake-0.7.2/bin/rake:7:in
`run': Illegal/unsupported escape squence near index 3
 (SyntaxError)
D:\MyDocuments\Temp\Temp\BlogDemo\db\migrate\002_add_column.rb

   ^
        from C:/Documents and Settings/Brian
Leonard/.netbeans/dev/jruby-0.9.8/lib/ruby/gems/1.8/gems/rake-0.7.2/bin/rake:7:in
`find'
        from C:/Documents and Settings/Brian
Leonard/.netbeans/dev/jruby-0.9.8/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1947:in
`run'
        from C:/Documents and Settings/Brian
Leonard/.netbeans/dev/jruby-0.9.8/lib/ruby/gems/1.8/gems/rake-0.7.2/bin/rake:7
        from C:\Documents and Settings\Brian
Leonard\.netbeans\dev\jruby-0.9.8\bin\rake:16:in `load'
        from C:\Documents and Settings\Brian
Leonard\.netbeans\dev\jruby-0.9.8\bin\rake:16

Comment 8 William Leonard 2007-03-30 15:30:36 UTC
Created attachment 40197 [details]
Migrate Database Error Output
Comment 9 William Leonard 2007-03-30 15:31:55 UTC
Created attachment 40198 [details]
Sample Project with Migrations for Testing
Comment 10 Torbjorn Norbye 2007-04-02 17:02:30 UTC
Did you edit your test configuration (in databases.yml) such that you have a jdbc database (derby) for the 
test configuration as well?  The default is mysql, which obviously won't work.  It looks from the output 
below like it is trying to access mysql drivers.

Also, is it possible that the version you were running didn't have the rake migrations support yet? If not 
I'm not sure how the Migrate Database menu didn't have the versions listed there - I'm just going through 
your sample application steps and I see both version 0 and 1 after adding the post model.

(I haven't set up a test database myself so I haven't tracked down the migrations part yet)
Comment 11 William Leonard 2007-04-02 19:48:09 UTC
OK, I'm now on Feature Level 0.51, which does show the To Version under the
Migrate Database menu (although only To Version 0, not 1). How are you
determining these values?

What is unlear to me is why I need to configure my test database. I'm not trying
to run tests. I just want migrate the database in my development enviroment. But
Migrate Database is execting my tests:

(in D:/MyDocuments/Temp/BlogDemo)

D:/Software/Ruby/InstantRails-1.6-win/InstantRails/ruby/bin/ruby -Ilib;test
"D:/Software/Ruby/InstantRails-1.6-win/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake/rake_test_loader.rb"
"test/unit/post_test.rb" 

Loaded suite
D:/Software/Ruby/InstantRails-1.6-win/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake/rake_test_loader

Started

.

Finished in 0.241 seconds.



1 tests, 1 assertions, 0 failures, 0 errors

D:/Software/Ruby/InstantRails-1.6-win/InstantRails/ruby/bin/ruby -Ilib;test
"D:/Software/Ruby/InstantRails-1.6-win/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake/rake_test_loader.rb"
"test/functional/blog_controller_test.rb" 

Loaded suite
D:/Software/Ruby/InstantRails-1.6-win/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake/rake_test_loader

Started

.

Finished in 0.12 seconds.



1 tests, 1 assertions, 0 failures, 0 errors

D:/Software/Ruby/InstantRails-1.6-win/InstantRails/ruby/bin/ruby -Ilib;test
"D:/Software/Ruby/InstantRails-1.6-win/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake/rake_test_loader.rb"
 



And it doesn't seem to do anything different if I select Current Version to
Version O).

Why does "Run Rake Target > db > mirgrate" behave differently than "Migrate
Database"

From the command line of the sample project I sent you I can run:

rake db:migrate (which will take me to the current version, 2)
rake db:migrate version=1 (which will take me back to version 1 - i.e., remove
the body column). 

That same functionality isn't working for me in NetBeans yet.
Comment 12 Torbjorn Norbye 2007-04-13 20:51:57 UTC
Thanks - this has now been fixed (as of version 0.71).
Comment 13 William Leonard 2007-04-15 23:22:14 UTC
It's better, but are you seeing both migrations in the list when you open the
attached project? There are 2, so I would expected the Migrate Database menu to show

To Current Version
------------------
To Version 1 #which removes the body column 
To Version 0 #which drops the posts table

Comment 14 Torbjorn Norbye 2007-04-16 15:41:55 UTC
When I open your attached project and open the "Migrate Database" context menu, I see 4 lines:

To Current Version
----------------
To Version 0
To Version 1
To Version 2

Are you saying you don't get the last line? If so that would be very strange.
Comment 15 William Leonard 2007-04-26 14:42:44 UTC
I don't get the last 2 lines, I only see:

To Current Version
------------------
To Version 0

I'll also attached a screen shot for you. Could be a Windows only issue.

Comment 16 William Leonard 2007-04-26 14:44:42 UTC
Created attachment 41733 [details]
Screen shot showing 2 migrations but only 1 entry in the Migrate Database menu
Comment 17 Torbjorn Norbye 2007-04-26 16:59:19 UTC
Interesting. The screenshot shows that it didn't find -either- of the two migrations ("Version 0" is 
hardcoded - it means remove everything from the database, and is present for all projects along with 
"Current Version".)
Comment 18 demisone 2007-05-24 21:08:13 UTC
Any news on this one?

The same is happening for me: not showing the number of migrations *at all*.
Only Version 0.

I'm using M9 with jruby

Any ideas on how to go to a specific version ? (under windows vista, with jruby
shipped with netbeans only installed)
Comment 19 Torbjorn Norbye 2007-05-24 21:12:29 UTC
I'm starting to think this is a bug which shows up only on Windows - the attached project works for me. 
Sigh, I need to get my hands on a Windows machine. I'm going to ping my boss again about getting a copy 
of Parallels and Windows for my Mac.
Comment 20 demisone 2007-05-24 21:28:46 UTC
Hm... Why would it be only in Windows...? :( I don't have any *nix os available
at the moment so i can't test the same projects there...

Two more hints:
-I run "Refresh Target List" -> Nothing happened
-I created a new migration from the "generate" option to test if netbeans would
"see" the new migration in a different project -> Didn't work either

P.S. 1: Should we change Issue type to defect?

P.S. 2: Should we also change Target Milestone? (6.0M8 has been released already
and this problem exists in M9 :D )

P.S. 2: Any chance of someone confirming that the problem it's windows specific? 
Comment 21 Torbjorn Norbye 2007-05-24 21:48:24 UTC
Thanks for the information - yes, it's a defect now that it's been implemented, I'm changing the issue 
type.

Some comments:
1) "Refresh Target List" - this has nothing to do with migrations, right? In other words, "Refresh Target 
List" is on the Rake context menu, and for migrations you're looking at the "Migrate To" menu item, 
right?

2) By "see the migration in a different project", do you mean that you created a brand new Rails project, 
created a migration in there and you still don't see a version 1 anywhere?

3) Which version of the Ruby IDE are you using? Perhaps I can build a customized version of the Rails 
project module which spits out some extra diagnostics for me to track this down, and have you try it?

Let me know if this is okay and I'll e-mail it to you (demisone@netbeans.org).
Comment 22 demisone 2007-05-24 22:31:21 UTC
1) Well i just thought to give it a try :)

2) Yes (you can check the the screenshot)

3) The full package of NetBeans M9. More info:

NetBeans IDE 6.0 Preview (M9, build 070502)
1.6.0; Java HotSpot(TM) Client VM 1.6.0-b105
Windows Vista version 6.0 running on x86
el_GR (nb); UTF-8

"Perhaps I can build a customized version of the Rails 
project module which spits out some extra diagnostics for me to track this down,
and have you try it?"

Yeah sure, i just don't know if i will be able to do it immediately. (demisone
at gmail)
Comment 23 demisone 2007-05-24 22:34:48 UTC
Created attachment 42753 [details]
"Migrate Database / To Version xx" not showing versions correctly (in a fresh new Rails project)
Comment 24 Torbjorn Norbye 2007-06-18 23:24:48 UTC
I finally got Windows installed on my laptop and could reproduce the problem; it was indeed a Windows-specific path handling bug. I've fixed it (and some 
related bugs in the Rails generator dialog and jar selection).  The fix is available in 2196 and later.
Comment 25 Jiri Kovalsky 2007-07-03 14:12:54 UTC
Reassigning this issue to newly created 'ruby' component.
Comment 26 Jiri Kovalsky 2007-07-03 14:43:44 UTC
Changing target milestone of all resolved Ruby issues from TBD to 6.0 Beta 1 build.