Removed affiliate table in favor of direct campaign URLs.
This commit is contained in:
@@ -1274,21 +1274,6 @@ exports.up = knex => Promise.resolve()
|
||||
.notNullable()
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('affiliates', (table) => {
|
||||
table.string('id')
|
||||
.primary()
|
||||
.unique()
|
||||
.notNullable();
|
||||
|
||||
table.text('url')
|
||||
.notNullable();
|
||||
|
||||
table.text('comment');
|
||||
|
||||
table.datetime('created_at')
|
||||
.notNullable()
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('banners', (table) => {
|
||||
table.string('id')
|
||||
.primary()
|
||||
@@ -1338,15 +1323,15 @@ exports.up = knex => Promise.resolve()
|
||||
.references('id')
|
||||
.inTable('entities');
|
||||
|
||||
table.string('affiliate_id')
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('affiliates');
|
||||
|
||||
table.string('banner_id')
|
||||
.references('id')
|
||||
.inTable('banners');
|
||||
|
||||
table.text('url')
|
||||
.notNullable();
|
||||
|
||||
table.text('comment');
|
||||
|
||||
table.datetime('created_at')
|
||||
.notNullable()
|
||||
.defaultTo(knex.fn.now());
|
||||
@@ -1370,8 +1355,8 @@ exports.up = knex => Promise.resolve()
|
||||
CREATE UNIQUE INDEX unique_actor_slugs_network ON actors (slug, entity_id, entry_id);
|
||||
CREATE UNIQUE INDEX unique_actor_slugs ON actors (slug) WHERE entity_id IS NULL;
|
||||
|
||||
CREATE UNIQUE INDEX unique_entity_campaigns_banner ON campaigns (entity_id, affiliate_id, banner_id);
|
||||
CREATE UNIQUE INDEX unique_entity_campaigns ON campaigns (entity_id, affiliate_id) WHERE banner_id IS NULL;
|
||||
CREATE UNIQUE INDEX unique_entity_campaigns_banner ON campaigns (entity_id, url, banner_id);
|
||||
CREATE UNIQUE INDEX unique_entity_campaigns ON campaigns (entity_id, url) WHERE banner_id IS NULL;
|
||||
|
||||
CREATE UNIQUE INDEX releases_search_unique ON releases_search (release_id);
|
||||
CREATE INDEX releases_search_index ON releases_search USING GIN (document);
|
||||
@@ -1561,6 +1546,10 @@ exports.up = knex => Promise.resolve()
|
||||
CREATE FUNCTION releases_is_new(release releases) RETURNS boolean AS $$
|
||||
SELECT EXISTS(SELECT true WHERE (SELECT id FROM batches ORDER BY created_at DESC LIMIT 1) = release.created_batch_id);
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
CREATE FUNCTION banners_ratio(banner banners) RETURNS real AS $$
|
||||
SELECT ROUND(banner.width::decimal / banner.height::decimal, 2);
|
||||
$$ LANGUAGE SQL STABLE;
|
||||
`);
|
||||
})
|
||||
// POLICIES
|
||||
@@ -1729,7 +1718,6 @@ exports.down = (knex) => { // eslint-disable-line arrow-body-style
|
||||
|
||||
DROP TABLE IF EXISTS banners_tags CASCADE;
|
||||
DROP TABLE IF EXISTS banners CASCADE;
|
||||
DROP TABLE IF EXISTS affiliates CASCADE;
|
||||
DROP TABLE IF EXISTS campaigns CASCADE;
|
||||
DROP TABLE IF EXISTS batches CASCADE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user