Yeah, it's needed here unless we want to recreate our existing dbs


On Tue, Jun 4, 2013 at 11:14 AM, Damon Snyder <notifications@github.com>wrote:

> In sql/if-modified-since.sql:
>
> > +    IF (NEW.modified_at >= OLD.modified_at) THEN
> > +        RETURN NEW;
> > +    ELSE
> > +        -- short circuit the update if the condition is not satisfied
> > +        RETURN NULL;
> > +    END IF;
> > +END;
> > +$$ LANGUAGE plpgsql;
> > +
> > +DROP TRIGGER IF EXISTS poky_only_if_unmodified_since ON poky;
> > +CREATE TRIGGER poky_only_if_unmodified_since
> > + BEFORE UPDATE ON poky
> > +   FOR EACH ROW EXECUTE PROCEDURE only_if_unmodified_since();
> > +
> > +ALTER TABLE poky ALTER COLUMN modified_at SET NOT NULL;
> > +ALTER TABLE poky ALTER COLUMN created_at SET NOT NULL;
>
> It's specified on the CREATE TABLE. Though for consistency, maybe I should
> add it here too. At some point, I think I'll merge this into the table.sql.
> … <#13f10664ad2e3bce_>
> On Tue, Jun 4, 2013 at 11:12 AM, Logan Linn <notifications@github.com>wrote:
> In sql/if-modified-since.sql: > + IF (NEW.modified_at >= OLD.modified_at)
> THEN > + RETURN NEW; > + ELSE > + -- short circuit the update if the
> condition is not satisfied > + RETURN NULL; > + END IF; > +END; > +$$
> LANGUAGE plpgsql; > + > +DROP TRIGGER IF EXISTS
> poky_only_if_unmodified_since ON poky; > +CREATE TRIGGER
> poky_only_if_unmodified_since > + BEFORE UPDATE ON poky > + FOR EACH ROW
> EXECUTE PROCEDURE only_if_unmodified_since(); > + > +ALTER TABLE poky ALTER
> COLUMN modified_at SET NOT NULL; > +ALTER TABLE poky ALTER COLUMN
> created_at SET NOT NULL; I think this needs DEFAULT NOW() The INSERT INTO
> poky (bucket, key, data) VALUES (b, k, d); below will fail without a
> default value — Reply to this email directly or view it on GitHub<
> https://github.com/drsnyder/poky/pull/9/files#r4529243> .
>  -- http://damonsnyder.net
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/drsnyder/poky/pull/9/files#r4529308>
> .
>