Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing index on historical table when using t.reference or index: true #173

Open
tagliala opened this issue Jun 20, 2022 · 0 comments
Open
Labels

Comments

@tagliala
Copy link
Member

tagliala commented Jun 20, 2022

Ruby: 3.0
Rails: 7.0
ChronoModel: master branch

migration

enable_extension :btree_gist

create_table :countries, temporal: true do |t|
  t.string :name
end

create_table :cities, temporal: true do |t|
  t.references :country
  t.string :name
end

Expected result

--
-- Name: index_cities_on_country_id; Type: INDEX; Schema: history; Owner: -
--

CREATE INDEX index_cities_on_country_id ON history.cities USING btree (country_id);

--
-- Name: index_cities_on_country_id; Type: INDEX; Schema: temporal; Owner: -
--

CREATE INDEX index_cities_on_country_id ON temporal.cities USING btree (country_id);

Actual result

--
-- Name: index_cities_on_country_id; Type: INDEX; Schema: temporal; Owner: -
--

CREATE INDEX index_cities_on_country_id ON temporal.cities USING btree (country_id);

Workaround

Create the index manually

create_table :countries, temporal: true do |t|
  t.string :name
end

create_table :cities, temporal: true do |t|
  t.references :country, index: false
  t.string :name
end

add_index :cities, :country_id
@tagliala tagliala added the bug label Jun 20, 2022
@tagliala tagliala changed the title Missing index on historical table when using t.reference Missing index on historical table when using t.reference or index: true Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant