Pregunta

Tengo una migración de rieles:

>> cat db/migrate/20091126031039_create_cards.rb 
class CreateCards < ActiveRecord::Migration
  def self.up
    create_table :cards do |t|
      t.string :number_hash
      t.int :number
      t.string :name
      t.string :type
      t.string :expiration
      t.int :sec_code

      t.timestamps
    end
  end

  def self.down
    drop_table :cards
  end
end

observe el " t.int: sec_code " línea. Parece que se ejecuta con éxito:

>> rake db:migrate(in /Users/aaronj1335/Sites/clarkbox)
==  CreateCards: migrating ====================================================
-- create_table(:cards)
   -> 0.4315s
==  CreateCards: migrated (0.4317s) ===========================================

pero el " sec_code " la columna no se crea:

mysql> describe cards;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment | 
| number_hash | varchar(255) | YES  |     | NULL    |                | 
| name        | varchar(255) | YES  |     | NULL    |                | 
| type        | varchar(255) | YES  |     | NULL    |                | 
| expiration  | varchar(255) | YES  |     | NULL    |                | 
| created_at  | datetime     | YES  |     | NULL    |                | 
| updated_at  | datetime     | YES  |     | NULL    |                | 
+-------------+--------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

¿por qué no se crea la columna sec_code? parece que debería obtener un error ...

¿Fue útil?

Solución

t.int probablemente debería ser t.integer. Dale una oportunidad.

En caso de duda, mareado siempre tiene algunas referencias geniales.

Otros consejos

Bueno, tampoco veo el " número " el campo se está creando correctamente, por lo que debe ser el tipo (t.int: falta el número)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top