8

Removing Rails & amp; migration

 3 years ago
source link: https://www.codesd.com/item/removing-rails-migration.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Removing Rails & amp; migration

advertisements

If the answer to this has already been discussed, please point me in the right direction. I have searched for this problem, but nothing I have found has worked in my case.

I've created tables that I would like to delete. I have deleted the models and the migrations, but when I attempt to recreate them then migrate, I get the following:

SQLite3::SQLException: table already exists, etc....

I've attempted to use an SQLite manager to delete them manually, but I'm not sure where the database file is located (other posts didn't help me here either). I am on Win 7, by the way.

I would like to know the proper way of doing this.


This is another easiest way of creating table and migration again. If you are using rails 3. run this commands to drop database and create it again .

rake db:drop # to drop database

rake db:create # to create same database

rake db:migrate # to migrate the data.

Related Articles

Rails db migrate error aborted while editing a field name after the first migration

I had named the add_column :users, :confirmed_at(confirmation_at), :datetime by accident. So I changed it to the appropriate field name :(confirmed_at) then I entered : rake db:rollback in command line. it was aborted for some reason with the message

Strong parameters in Rails - automatic migration addition

After updating some 15-20 entries of my new database I realized my data wasn't updated. I just read about the strong parameters in Rails 4.0 and it turned out that I hadn't whitelisted them. I understand the reason for having them (although I complet

How to create a new table with a unique index in an Active Record / Rails 4 migration

How do I create a new table, through a rails migration, and add an unique index to it? In the docs I found how to add a index to a table after it's been created, but how do you do both -- create the table, and add the unique index -- in the same migr

Rails generates migrations

I currently have migration called Products, and I simply want to add few more strings to this migration such as description and product type. What is the best way to do this? class CreateProducts < ActiveRecord::Migration def change create_table :pro

Error Running Ruby on Rails Database Migration

I am installing the devise gem for authentication in a Ruby on Rails application and I ran the database migration like this: rake db:migrate and got this error: undefined method `reference' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x93

Rails Database Migration Fails with "Duplicate Column Name: E-mail"

I am fairly new to Rails and I'm currently installing the devise gem. When I created a User model and attempted to migrate the database: $ rails generate devise User $ rake db:migrate I get the following error response: == 20160717064710 AddDeviseToU

Rails 3 migrations: Add a reference column?

If I create a new rails 3 migration with (for example) rails g migration tester title:tester user:references , everything works fine...however if I add a column with something along the lines of: rails g migration add_user_to_tester user:references t

Rails & amp; Postgres: Migration to change_colomn gives an error & ldquo; Can not be broadcast to type timestamp without time zone & rdquo;

A Rails migration to turn a "deleted_at" time column to a datetime column failed. Any ideas on how to solve this? It's a fresh install of Postgres if that is relevant. -- change_column(:products, :deleted_at, :datetime) PGError: ERROR: column &q

Rails & amp; SQLite: migration to add a unique index and allow null values

I want to force e-mails to be unique at the database level, but I also want to allow for null e-mail values. I get the following error with the migration. Current Schema create_table "users", force: true do |t| t.string "email", defaul

Rails 3: Migrate data

My Rails 3 app has a User model and a Profile model. A User has_one Profile. Currently the Profile has attributes first_name and last_name. While I'm not sure why you might want to change them, I originally imagined these should be changeable and so

Rails 4 Migration | Add a table with reference

I am attempting to create a Collaboration table in my Rails 4 project, but I've run into an issue. I wish it to belong_to a single user, the collaborator. I ran the following command to generate the model and the migration, which I've also copied bel

Rails 3 Migration and application.rb

I inherited a Rails project and was asked to update it so I am migrating the Rails 2.2.2 project to Rails 3.2. I went through a few migration tutorials and ran the rails upgrade script and it loads fine when the default /public/index.html is there. I

Rails & amp; Rolify: Add a default role to the creative?

Currently I'm using Rolify & CanCan to manage roles and abilities in my Rails 3 app. My question is: How can I get a user to have a role by default on creation? for example, if I have a "user" role, ¿How can I make all the users that registe

Remove constraints in migration migration

I'm adding a unique constraint in a migration via the migrations.changeColumn function. Adding the constraint works, but since you need to provide a "backwards migration", removing it the same way does not. It doesn't give any errors when migrat

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK