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 6054197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:07:34+00:00 2026-05-23T08:07:34+00:00

I have a data structure: t.integer :userID t.string :apikey t.integer :characterID The userID should

  • 0

I have a data structure:

  t.integer :userID
  t.string :apikey
  t.integer :characterID

The userID should be the primary key (name is not important, it can default to :id). However, I don’t want it to be auto incrementing or anything else, just take the value provided and write it into the database.

How do I have to adjust the migration and the model to achieve what I want?

  • 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-23T08:07:34+00:00Added an answer on May 23, 2026 at 8:07 am
     create_table(:my_table, :primary_key => 'userID') do |t|
       # Primary key column will be created automatically
       # Do not create here
       # t.column :userID, :integer, :null => false
       ...
     end
    

    Or

    create_table :my_table, {:id => false} do |t|
      t.integer :userID
      t.string :apikey
      t.integer :characterID
      t.timestamps
     end
     execute "ALTER TABLE my_table ADD PRIMARY KEY (userID);"
    

    And don’t forget to put this line somewhere in model:

     set_primary_key :userID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data stream with the following structure user_id (integer) user_name (string) The
Guys, I have a data structure which has 25 distinct keys (integer) and a
I have a data structure that represents C# code like this: class Namespace: string
I have Preferences data structure where I have string Value field and enum for
I have a data structure which uses composite ids (Which I dont wish to
I have a data structure defined as struct myDataStruct { int32_t header; int16_t data[8];
I have a data structure where an entity has times stored as an int
I have a data structure which is as given below: class File { public
I have the following data structure (a list of lists) [ ['4', '21', '1',
I have a tree data structure that is L levels deep each node has

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.