Function ensureColumnExists

  • Adds column to table with definition (its type and constraints, as SQL: TEXT NOT NULL DEFAULT 'none') when the table lacks it, on PostgreSQL or SQLite. Resolves true when it added the column and false when the table had it. The table may be schema-qualified on PostgreSQL (app.notes).

    Parameters

    Returns Promise<boolean>

    await ensureColumnExists(db, 'notes', 'archived_at', d.columnType('timestamp'));