jam-cloud/db/up/home_page_promos.sql

27 lines
945 B
SQL

--
CREATE TABLE promotionals(
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
/* allows for single table inheritance */
type VARCHAR(128) NOT NULL DEFAULT 'JamRuby::PromoBuzz',
/* state machine */
aasm_state VARCHAR(64) DEFAULT 'hidden',
/* order of promo within its types */
position integer NOT NULL DEFAULT 0,
/* standard AR timestamps */
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
/* references latest recording or session polymorphically */
latest_id VARCHAR(64) DEFAULT NULL,
latest_type VARCHAR(128) DEFAULT NULL,
/* used for buzz promo type */
original_fpfile_photo VARCHAR(8000) DEFAULT NULL,
photo_url VARCHAR(2048) DEFAULT NULL,
text_short VARCHAR(512) DEFAULT NULL,
text_long VARCHAR(4096) DEFAULT NULL
);
CREATE INDEX promo_latest_idx ON promotionals(latest_id, latest_type);