Project

General

Profile

Actions

Bug #421

closed

Migration AddEnabledToHosts fails with PostgreSQL

Added by Jochen Schalanda about 14 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
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)

Files

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
Actions #2

Updated by Jochen Schalanda about 14 years ago

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

Updated by Ohad Levy about 14 years ago

  • Status changed from Ready For Testing to Closed
Actions

Also available in: Atom PDF