Skip to content

Commit

Permalink
Torii only create member index if not exists (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
broody authored Oct 31, 2023
1 parent f02b313 commit 648e9f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/torii/core/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ impl Sql {
if let Ok(cairo_type) = Primitive::from_str(&member.ty.name()) {
query.push_str(&format!("external_{name} {}, ", cairo_type.to_sql_type()));
indices.push(format!(
"CREATE INDEX idx_{table_id}_{name} ON [{table_id}] (external_{name});"
"CREATE INDEX IF NOT EXISTS idx_{table_id}_{name} ON [{table_id}] \
(external_{name});"
));
} else if let Ty::Enum(e) = &member.ty {
let all_options = e
Expand All @@ -347,7 +348,8 @@ impl Sql {
));

indices.push(format!(
"CREATE INDEX idx_{table_id}_{name} ON [{table_id}] (external_{name});"
"CREATE INDEX IF NOT EXISTS idx_{table_id}_{name} ON [{table_id}] \
(external_{name});"
));

options = Some(format!(
Expand Down

0 comments on commit 648e9f2

Please sign in to comment.