Closed kaaveland closed 1 month ago
This one sparks the most joy right now, going to take a look at what we need to do this and get eugene lint
deployed as a service somewhere!
I think it makes sense to introduce usage of cargo workspaces at this point, since we shouldn't have to build a command line program that contains a webserver. axum
makes the most sense right now, I think, it looks it's on a 📈
curl -s --header 'Content-Type: application/json' -XPOST https://kaveland.no/eugene/app/lint.json -d '{"script": "-- file: foo.sql\ncreate index books_idx on books(title);"}' | python -m json.tool
[
{
"name": "foo.sql",
"statements": [
{
"statement_number": 1,
"line_number": 1,
"sql": "-- file: foo.sql\ncreate index books_idx on books(title)",
"triggered_rules": [
{
"id": "E6",
"name": "Creating a new index on an existing table",
"condition": "A new index was created on an existing table without the `CONCURRENTLY` keyword",
"effect": "This blocks all writes to the table while the index is being created",
"workaround": "Run `CREATE INDEX CONCURRENTLY` instead of `CREATE INDEX`",
"help": "Statement takes `ShareLock` on `public.books`, blocking writes while creating index `public.books_idx`",
"url": "https://kaveland.no/eugene/hints/E6/"
},
{
"id": "E9",
"name": "Taking dangerous lock without timeout",
"condition": "A lock that would block many common operations was taken without a timeout",
"effect": "This can block all other operations on the table indefinitely if any other transaction holds a conflicting lock while `idle in transaction` or `active`",
"workaround": "Run `SET LOCAL lock_timeout = '2s';` before the statement and retry the migration if necessary",
"help": "Statement takes lock on `public.books`, but does not set a lock timeout",
"url": "https://kaveland.no/eugene/hints/E9/"
}
]
}
],
"passed_all_checks": false,
"skip_summary": true
}
]
Or this simple one:
curl -s -XPOST https://kaveland.no/eugene/app/lint.raw -d 'create index books_idx on books(title);'
unnamed:1 E6 Creating a new index on an existing table https://kaveland.no/eugene/hints/E6/
unnamed:1 E9 Taking dangerous lock without timeout https://kaveland.no/eugene/hints/E9/
I feel like we should have a textarea that we can expose on the webpage before closing this one, going to take a look at that next.
Alternatively, make it send email as per Zawinski's law. More seriously, I think
cargo install
is a barrier to getting users and I think a simple webpage with a backend that runseugene lint
could be excellent to use from documentation, and to share to people who are working on migrations but can't install.Also I'd like to learn a rust web framework just to check the state of affairs. warp and axum both look pretty exciting to me.