Message from discussion
migration problem
Received: by 10.58.153.130 with SMTP id vg2mr7292064veb.30.1352830149134;
Tue, 13 Nov 2012 10:09:09 -0800 (PST)
X-BeenThere: rubyonrails-talk@googlegroups.com
Received: by 10.52.25.114 with SMTP id b18ls700136vdg.6.gmail; Tue, 13 Nov
2012 10:08:14 -0800 (PST)
Received: by 10.52.34.205 with SMTP id b13mr4528332vdj.3.1352830094500;
Tue, 13 Nov 2012 10:08:14 -0800 (PST)
Date: Tue, 13 Nov 2012 10:08:13 -0800 (PST)
From: roelof <rwob...@hotmail.com>
To: rubyonrails-talk@googlegroups.com
Message-Id: <f937b8b4-aa95-44e2-a5c9-b50f09ec2824@googlegroups.com>
Subject: migration problem
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_2_10194728.1352830093951"
------=_Part_2_10194728.1352830093951
Content-Type: multipart/alternative;
boundary="----=_Part_3_13872187.1352830093951"
------=_Part_3_13872187.1352830093951
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Hello,
I want to use username so I can log in with username.
So I made this migration file :
class AddDeviseToUsers < ActiveRecord::Migration
def self.up
change_table(:users) do |t|
## Database authenticatable
t.string :username, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, :default => 0 # Only if lock strategy
is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or
:both
# t.datetime :locked_at
## Token authenticatable
# t.string :authentication_token
# Uncomment below if timestamps were not included in your original
model.
# t.timestamps
end
add_index :users, :email
add_index :users, :username, :unique => true
add_index :users, :reset_password_token, :unique => true
add_index :users, :confirmation_token, :unique => true
add_index :users, :unlock_token, :unique => true
add_index :users, :authentication_token, :unique => true
end
def self.down
# By default, we don't want to make any assumption about how to roll
back a migration when your
# model already existed. Please edit below which fields you would like
to remove in this migration.
raise ActiveRecord::IrreversibleMigration
end
end
But now I get this error message : SQLite3::SQLException: no such table:
users: ALTER TABLE "users" ADD "username" varchar(255) DEFAULT '' NOT NULL
Anyone a idea how to solve this ?
This is a clean install.
Roelof
------=_Part_3_13872187.1352830093951
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Hello, <br><br>I want to use username so I can log in with username.<br>So =
I made this migration file : <br><br>class AddDeviseToUsers < ActiveReco=
rd::Migration<br> def self.up<br> change_table(:use=
rs) do |t|<br> ## Database authenticatable<br=
> t.string :username, =
:null =3D> false, :default =
=3D> ""<br> t.string :encrypted_password, =
:null =3D> false, :default =3D> ""<br><br> &nb=
sp; ## Recoverable<br> t.string :=
reset_password_token<br> t.datetime :reset_pa=
ssword_sent_at<br><br> ## Rememberable<br>&nb=
sp; t.datetime :remember_created_at<br><br> &n=
bsp; ## Trackable<br> t.int=
eger :sign_in_count, :default =3D> 0<br> &n=
bsp; t.datetime :current_sign_in_at<br> t.dat=
etime :last_sign_in_at<br> t.string &nbs=
p; :current_sign_in_ip<br> t.string &nbs=
p; :last_sign_in_ip<br><br> ## Confirmable<br=
> # t.string :confirmation_token<=
br> # t.datetime :confirmed_at<br>  =
; # t.datetime :confirmation_sent_at<br>  =
; # t.string :unconfirmed_email # Only if using rec=
onfirmable<br><br> ## Lockable<br>  =
; # t.integer :failed_attempts, :default =3D> 0 =
# Only if lock strategy is :failed_attempts<br> &nbs=
p; # t.string :unlock_token # Only if unlock strategy is :email=
or :both<br> # t.datetime :locked_at<br><br>=
## Token authenticatable<br> &nbs=
p; # t.string :authentication_token<br><br><br> &nbs=
p; # Uncomment below if timestamps were not included in your or=
iginal model.<br> # t.timestamps<br> &nb=
sp; end<br><br> add_index :users, :email<br> &=
nbsp; add_index :users, :username,  =
; :unique =3D> true<br> &=
nbsp; add_index :users, :reset_password_token, :unique =3D> true<br>&nbs=
p; add_index :users, :confirmation_token, :unique =
=3D> true<br> add_index :users, :unlock_token, &n=
bsp; :unique =3D> true<br> &nbs=
p; add_index :users, :authentication_token, :unique =3D> true<br>&=
nbsp; end<br><br> def self.down<br> # By default, w=
e don't want to make any assumption about how to roll back a migration when=
your<br> # model already existed. Please edit below whic=
h fields you would like to remove in this migration.<br> =
raise ActiveRecord::IrreversibleMigration<br> end<br>end<br><br><br>B=
ut now I get this error message : SQLite3::SQLException: no such tabl=
e: users: ALTER TABLE "users" ADD "username" varchar(255) DEFAULT '' NOT NU=
LL<br><br>Anyone a idea how to solve this ?<br>This is a clean install.<br>=
<br>Roelof<br><br>
------=_Part_3_13872187.1352830093951--
------=_Part_2_10194728.1352830093951--