Change Type
Enhancement
Current API
The AddIndex function in the ORM returns a string instead of a builder. I can't use it effectively, so I have to add indexes manually every time.
Proposed API
AddIndex must return a pointer to its own data type.
Rationale
This will greatly simplify the process of creating migrations.
Migration Path
Before:
queries.push_back(
builder.AddForeignKey("chat_id", "chats", "id")
.AddForeignKey("sender_id", "users", "id")
.AddIndex("idx_messages_chat_id", { "chat_id" })
);
queries.push_back(
builder.AddIndex("idx_messages_sender_id", { "sender_id" })
);
queries.push_back(
builder.AddIndex("idx_messages_created_at", { "created_at" })
);
After:
queries.push_back(
builder.AddForeignKey("chat_id", "chats", "id")
.AddForeignKey("sender_id", "users", "id")
.AddIndex("idx_messages_chat_id", { "chat_id" })
.AddIndex("idx_messages_sender_id", { "sender_id" })
.AddIndex("idx_messages_created_at", { "created_at" })
);
Backward Compatibility
Yes, this will break existing code.
The vector should store a string, not the builder. You will need to add an extra method to retrieve the string from the builder.
Usage Examples
Change Type
Enhancement
Current API
The
AddIndexfunction in the ORM returns a string instead of a builder. I can't use it effectively, so I have to add indexes manually every time.Proposed API
AddIndexmust return a pointer to its own data type.Rationale
This will greatly simplify the process of creating migrations.
Migration Path
Before: queries.push_back( builder.AddForeignKey("chat_id", "chats", "id") .AddForeignKey("sender_id", "users", "id") .AddIndex("idx_messages_chat_id", { "chat_id" }) ); queries.push_back( builder.AddIndex("idx_messages_sender_id", { "sender_id" }) ); queries.push_back( builder.AddIndex("idx_messages_created_at", { "created_at" }) ); After: queries.push_back( builder.AddForeignKey("chat_id", "chats", "id") .AddForeignKey("sender_id", "users", "id") .AddIndex("idx_messages_chat_id", { "chat_id" }) .AddIndex("idx_messages_sender_id", { "sender_id" }) .AddIndex("idx_messages_created_at", { "created_at" }) );Backward Compatibility
Yes, this will break existing code.
The vector should store a string, not the builder. You will need to add an extra method to retrieve the string from the builder.
Usage Examples