iosswiftsqlitesqlite.swift

How to delete table or update column with SQLite.swift ?


I need to re-create my table in my database. Is there anyway to update table's columns or delete table with SQLite.swift ?


Solution

  • Link to docs

    Assuming you have your variable for the open database:

    let db = Database("path/to/db.sqlite3")
    
    // what table to drop and recreate
    db.drop(table: yourTable, ifExists: true)
    

    And for altering a table

    db.alter(table: yourTable, add: suffix)