How to create composite-primary-key in rails 4

Viewed 3333

Please help me to convert this PostgreSQL table to rails migration file and model

CREATE DATABASE ip2location WITH ENCODING 'UTF8'; \c ip2location

CREATE TABLE ip2location_db1(
  ip_from integer(10) NOT NULL,
  ip_to integer(10) NOT NULL,
  country_code character(2) NOT NULL,
  country_name character varying(64) NOT NULL,
  CONSTRAINT ip2location_db1_pkey PRIMARY KEY (ip_from, ip_to)
);
  • Do i want to create rails model to retrieve data
2 Answers
Related