-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
db: make value.*_values TEXT instead of String(255) #2293
base: master
Are you sure you want to change the base?
Conversation
This is as deployed on the beta bot I run. |
This makes perfect sense, and I'm surprised none of us thought about the potential issues in #1446 or follow-ups. Since there's no mechanism yet for DB schema migrations, how do others want to handle this? There is precedent for a "migrate database" script that bot owners are instructed to run before starting a new version of the bot, and that's the simplest option. @RustyBower Does SQLAlchemy offer some simple automatic migration feature we could use, since VARCHAR to TEXT is quite possibly the simplest schema change ever? Alembic seems a bit heavy for this, not that I know how to use it anyway. |
I'll test the migration this evening. Otherwise we can make some "prerun" script that runs that validates the state of the database. |
Also IIRC, the reason everything is set for String(255) was either compatibility with the old database or because of SQLite weirdness with SQLAlchemy... |
Digging into this further. This is super breaking, because SQLite doesn't support the alter column functionality that other SQL engines support (https://www.sqlite.org/omitted.html) Although it appears you can hack around it with Alembic's batch_alter_table functionality (https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.batch_alter_table) |
SQLite hasn't seemed to exhibit the originally described problem with column value length, though. It doesn't appear to have any concept of constrained text length, unless I'm just missing that part of the datatype documentation. But that Alembic feature looks purpose designed to work around such issues if I am missing something in the SQLite docs. |
I think you're correct. Although trying to implement this dynamically to leverage db.get_uri() function from the bot is not as straightforward as I would have hoped. You can leverage some python magic in the env.py file for Alembic to dynamically generate the SQLAlchemy URI to use, but I need an instantiating SopelDB to call that... |
About getting a SopelDB, all you need is the config filename. Pass the filename to a new Config instance, then pass the Config instance to a new SopelDB instance. You can probably steal a lot of Config setup logic from the CLI code (e.g. for (An aside: I see we don't actually compile the docstrings for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a mental note to look further into Alembic. I already used it on a previous project with custom migrations and custom commands, so that shouldn't be too much of a trouble, at least for Sopel's migrations. For plugins, that'll be another thing, yet I already have some ideas to allow a plugin author to hooks their migrations to Sopel's future db migration command.
Can we reasonably expect this not to break existing SQLite instances—the default and therefore majority? If this has to be migrated only for non-default RDBMS backends, I'm a lot less concerned by the idea of merging before the migration is in place. 😅 |
Existing installations can simply choose to apply needed. I'm fairly confident it can't cause any damage to them on either schema simply by merging this without an explicit migration. |
@RhinosF1 Except for SQLite users (again, the default), there is no |
This should be handled via #2317 |
Yes. Other things took priority, while this is at the back of my head. |
I think we should leave this for 9.0, given that there's been no progress on database migrations in 9 months. Sopel 7.x is getting pretty long in the tooth, and it's really time we tied up our loose ends and started on a release. Migration requirements:
Originally posted by @Exirel in #2317 (comment) |
Description
Tin. Fixes #2291
Checklist
make qa
(runsmake quality
andmake test
)