Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

modify table

DUMP TABLE SCHEMA

sqlite>.schema
CREATE TABLE auditlog (
        id INTEGER NOT NULL,
        a_uid INTEGER NOT NULL,
        a_action VARCHAR(255) NOT NULL,
        a_when DATE NOT NULL,
        a_previous_entry TEXT,
        a_new_entry TEXT,
        PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS "notes" (
    id INTEGER NOT NULL,
    n_title VARCHAR(128) NOT NULL,
    n_note_data TEXT,
    n_contact_id INTEGER NOT NULL,
    n_event_date DATE NOT NULL,
    n_follow_up DATE NOT NULL,
    n_status VARCHAR(64) NOT NULL,
    n_is_child BOOLEAN DEFAULT FALSE,
    n_is_parent BOOLEAN DEFAULT TRUE,
    n_parent_id INTEGER,
    PRIMARY KEY (id),
    FOREIGN KEY(n_parent_id) REFERENCES "notes"(id)
);

ALTER a Table:

sqlite> ALTER TABLE users ADD COLUMN password_hash VARCHAR(128);

VERIFY Table Structure with Pragma:

sqlite> PRAGMA table_info(users);
0|id|INTEGER|1||1
1|u_first_name|VARCHAR(64)|1||0
2|u_last_name|VARCHAR(64)|1||0
3|u_email|VARCHAR(120)|1||0
4|u_role|VARCHAR(64)|1||0
5|u_status|VARCHAR(64)|1||0
6|password_hash|VARCHAR(128)|0||0