-
Notifications
You must be signed in to change notification settings - Fork 34
auto alter table schema #97
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
It's really annoying to have to call table drop or keep track of schema.ensure. In nvim-telescope/telescope-frecency.nvim#35, I was trying to debug and understand why count field keep being nil, even though the schema has default=0. It turns out the calling files.schema() returned an old schema, which means that the new schema has not effect on pre-existing table.
I'd like to compare the sql table schema and user provided schema and compare
between them, and if they are different. I'd like table module to auto alter.
The full table schema information as it exists in C side can be found with db:schema("files", true), it output something like that
{
def = {},
info = {
count = { cid = 0, primary = false, required = false, type = "INTEGER" },
id = { cid = 1, primary = true, required = false, type = "INTEGER" },
path = { cid = 2, primary = false, required = false, type = "TEXT" }
},
req = {},
types = { count = "INTEGER", id = "INTEGER", path = "TEXT" }
}In telescope-frecency case, I wanted it to change to the following:
{
def = { count = "0" },
info = {
count = { cid = 0, default = "0", primary = false, required = false, type = "integer" },
id = { cid = 1, primary = true, required = true, type = "integer" },
path = { cid = 2, primary = false, required = false, type = "string" }
},
req = {},
types = { count = "integer", id = "integer", path = "string" }
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request