Skip to content

Instantly share code, notes, and snippets.

@chriscarlsondev
Created July 1, 2019 15:41
Show Gist options
  • Save chriscarlsondev/8e45a2971811bdc60945f0b1d5832e87 to your computer and use it in GitHub Desktop.
Save chriscarlsondev/8e45a2971811bdc60945f0b1d5832e87 to your computer and use it in GitHub Desktop.
SQL statements to create a shopping list table and enum
DROP TYPE IF EXISTS grocery;
CREATE TYPE grocery AS ENUM (
'Main',
'Snack',
'Lunch',
'Breakfast'
);
CREATE TABLE IF NOT EXISTS shopping_list (
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
name TEXT NOT NULL,
price decimal(12,2) NOT NULL,
date_added TIMESTAMP DEFAULT now() NOT NULL,
checked BOOLEAN DEFAULT false NOT NULL,
category grocery NOT NULL
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment