Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6848589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:53:14+00:00 2026-05-27T00:53:14+00:00

I have an existing database structure created outside or Rails. I’ve edited one of

  • 0

I have an existing database structure created outside or Rails. I’ve edited one of the db/migrate files to include all the proper columns (not sure if this is the right way to do it) yet in the app or even in the interactive console, Rails is malforming the SQL necessary to query the table, specifically it is missing the ID column.

SELECT `dvds`.* FROM `dvds` WHERE (`dvds`.`` >= 0) ORDER BY `dvds`.`` ASC LIMIT 1000 

I’ve also ran rake db:create after editing the migrate file with the proper column names and types.

How do I tell Rails what the current structure is?

This happened to me before and I think I had to end up deleting all the migrate files and generating some files from scratch. I honestly can’t remember what I did to fix it (should have written it down) but I’m sure there is a file I can edit to let Rails know the structure no?

Table schema:

 `id` int(11) unsigned NOT NULL,
  `title` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `studio` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
  `released` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
  `status` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
  `sound` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  `versions` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
  `price` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
  `rating` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  `year` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  `genre` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
  `aspect` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  `upc` varchar(155) CHARACTER SET utf8 DEFAULT NULL,
  `dvd_realease` timestamp NULL DEFAULT NULL,
  `timestamp` timestamp NULL DEFAULT NULL,
  `directors` varchar(342) CHARACTER SET utf8 DEFAULT NULL,
  `actors` varchar(342) CHARACTER SET utf8 DEFAULT NULL

Migrate file:

class CreateDvds < ActiveRecord::Migration
  def change
    create_table :dvds do |t|
        t.integer   :id
        t.string    :title
        t.string    :studio
        t.string    :released
        t.string    :status
        t.string    :sound
        t.string    :versions
        t.string    :price
        t.string    :rating
        t.string    :year
        t.string    :genre
        t.string    :aspect
        t.string    :upc
        t.timestamp :dvd_release
        t.timestamps
        t.string    :directors
        t.string    :actors

    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:53:14+00:00Added an answer on May 27, 2026 at 12:53 am

    For this particular example single table/model you do not have to “tell” Rails about the current structure of your database. ActiveRecord will do this for you. There is no file you update for this to work.

    Ensure the dvds table has a primary key of “id” then all you need to do is have ActiveRecord class of Dvd. Migrations are only required if you are updating the database in anyway (which it appears you are not).

    This is a useful talk for using rails with legacy databases slidesha.re/NbOo1 He discusses a gem to allow rails to handle composite primary keys bit.ly/MvEYk

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing database in mysql. One of my tables has discontinuous ids.
I have all my SQL stored in source control in the following structure Database
I have an existing SQL Server database whose structure I can't really change, although
I have an existing database with the table Transactions in it. I have added
I have an existing database of a film rental system. Each film has a
I have an existing database that has some testing data into and I'm interested
I have an existing database containing some pictures in blob fields. For a web
I have an existing database with tables which each have 4 partitions (there are
I have an existing database with users and administrators in different tables. I am
I currently have an existing database and I am using the LINQtoSQL generator tool

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.