Project

General

Profile

Bug #421

Migration AddEnabledToHosts fails with PostgreSQL

Added by Jochen Schalanda over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

The database migration AddEnabledToHosts in db/migrate/20100823181036_add_enabled_to_hosts.rb fails when being run with PostgreSQL as database. In contrast to SQLite and MySQL, PostgreSQL is rather serious about its type-system.

# rake db:migrate
(in /srv/foreman)
==  CreateNotices: migrating ==================================================
-- create_table(:notices)
NOTICE:  CREATE TABLE will create implicit sequence "notices_id_seq" for serial column "notices.id" 
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "notices_pkey" for table "notices" 
   -> 0.4877s
-- create_table(:user_notices, {:id=>false})
   -> 0.0011s
==  CreateNotices: migrated (0.4891s) =========================================

==  AddEnabledToHosts: migrating ==============================================
-- add_column(:hosts, :enabled, :boolean, {:default=>1})
rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR:  column "enabled" is of type boolean but default expression is of type integer
HINT:  You will need to rewrite or cast the expression.
: ALTER TABLE "hosts" ALTER COLUMN "enabled" SET DEFAULT 1
class AddEnabledToHosts < ActiveRecord::Migration

(See full trace by running task with --trace)
0001-Fixes-bug-421-change-literal-1-to-true-in-database-m.patch 0001-Fixes-bug-421-change-literal-1-to-true-in-database-m.patch 870 Bytes Proposed trivial patch, tested against PostgreSQL and SQLite. Jochen Schalanda, 10/31/2010 02:09 PM

Associated revisions

Revision 83940766 (diff)
Added by Jochen Schalanda over 8 years ago

Fixes #421 - change literal 1 to true in database migration AddEnabledToHosts.

History

#2 Updated by Jochen Schalanda over 8 years ago

  • Status changed from New to Ready For Testing
  • % Done changed from 0 to 100

#3 Updated by Ohad Levy over 8 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF