stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.57k stars 1.54k forks source link

Add support for removing columns #1154

Closed jverkoey closed 1 year ago

jverkoey commented 1 year ago

Similar to try db.run(users.addColumn(suffix)), it would be useful to also be able to delete columns using syntax like try db.run(users.deleteColumn(suffix))

jverkoey commented 1 year ago

In the absence of such a function, something like the following can be ran:

try db.execute("""
    BEGIN TRANSACTION;
    ALTER TABLE your-table
    DROP COLUMN your-column;
    COMMIT TRANSACTION;
    """
)
jberkel commented 1 year ago

a future version will offer full support for schema migrations, it's not quite finished yet

jverkoey commented 1 year ago

Thank you! 🙏