Bug #536

db:migrate worked with errors if i use oracle db

Added by Nikolay Aralovets over 1 year ago. Updated 10 months ago.

Status:Need more information Start:12/15/2010
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:DB migrations
Target version:-
Backlog:No Difficulity:
Votes: 0

Description

Hello,
I try to use Oracle 10.2.0.5 for Foreman 0.1-6 backend. In process create schema I see next issue:
1. In file db/migrate/20090730152224_create_ptables.rb
t.string :layout, :limit => 4096, :null => false
and Oracle generates error:
CreatePtables: migrating ================================================
-- create_table(:ptables)
rake aborted!
An error has occurred, all later migrations canceled:

OCIError: ORA-00910: specified length too long for its datatype: CREATE TABLE "PTABLES" ("ID" NUMBER NOT NULL PRIMARY KEY, "NAME" VARCHAR2 NOT NULL, "LAYOUT" VARCHAR2 NOT NULL, "OPERATINGSYSTEM_ID" NUMBER, "CREATED_AT" DATE, "UPDATED_AT" DATE)
2. At execution scropts:
- 20090915030726_change_report_field_type_to_text.rb
- 20100115021803_change_mysql_reports_column.rb
- 20100325142616_update_fact_names_and_values_to_bin.rb
- 20101018120548_create_messages.rb
- 20101018120603_create_sources.rb
I see error:
ChangeReportFieldTypeToText: migrating ==================================
rake aborted!
An error has occurred, all later migrations canceled:

undefined method `[]' for nil:NilClass

History

Updated by Ohad Levy over 1 year ago

I have no oracle db to test, but can you try changing the following line in db/migrate/20090730152224_create_ptables.rb

t.string :layout, :limit => 4096, :null => false

to
t.text :layout, :null => false

Updated by Nikolay Aralovets over 1 year ago

It's not worked, because Oracle needs to set size for datatype. I change this as follows:
t.string :layout, :limit => 4000, :null => false
4000 is max size for datatype varchar2

Updated by Nikolay Aralovets over 1 year ago

Variant of a solution of a problem 2:
Add in if .. end condition else "do nothing" :)
For example in 20090915030726_change_report_field_type_to_text.rb add:
if ActiveRecord::Base.connection.instance_values["config"][:adapter] == "mysql"
execute "ALTER TABLE reports MODIFY log text;"
else
'do nothing'
end

Updated by Ohad Levy over 1 year ago

Nikolay Aralovets wrote:

Variant of a solution of a problem 2: Add in if .. end condition else "do nothing" :) For example in 20090915030726_change_report_field_type_to_text.rb add: if ActiveRecord::Base.connection.instance_values["config"][:adapter] == "mysql" execute "ALTER TABLE reports MODIFY log text;" else 'do nothing' end

would you like to submit it as a patch for this ticket? (best if you want to use git so we can keep your details within the official foreman repo).

Updated by Ohad Levy 10 months ago

  • Status changed from New to Need more information

Hi,

Does this ticket still relevant?

Also available in: Atom PDF