Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove use of rust in migration #704

Merged
merged 2 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

10 changes: 0 additions & 10 deletions migrations/postgres/2019-04-28-201506_create_tantivy_index/up.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
-- Your SQL goes here
--#!|conn: &Connection, path: &Path| {
--#! super::timeline::Timeline::new_for_instance(conn, "Local feed".into(), "local".into()).expect("Local feed creation error");
--#! super::timeline::Timeline::new_for_instance(conn, "Federated feed".into(), "all".into()).expect("Federated feed creation error");
--#!
--#! for i in 0.. {
--#! if let Some(users) = super::users::User::get_local_page(conn, (i * 20, (i + 1) * 20)).ok().filter(|l| !l.is_empty()) {
--#! for u in users {
--#! super::timeline::Timeline::new_for_user(conn, u.id, "Your feed".into(), format!("followed or author in [ {} ]", u.fqn)).expect("User feed creation error");
--#! }
--#! } else {
--#! break;
--#! }
--#! }
--#!
--#! Ok(())
--#!}
INSERT INTO timeline_definition (name, query) VALUES
('Local feed', 'local'),
('Federated feed', 'all');
INSERT INTO timeline_definition (user_id,name,query)
select id,'Your feed',CONCAT('followed or [',fqn,']') from users;
8 changes: 8 additions & 0 deletions migrations/postgres/2019-12-10-104935_fill_timelines/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DELETE FROM timeline WHERE id IN
(
SELECT timeline.id FROM timeline
INNER JOIN timeline_definition ON timeline.timeline_id = timeline_definition.id
WHERE timeline_definition.query LIKE 'followed or [%]' OR
timeline_definition.query = 'local' OR
timeline_definition.query = 'all'
);
17 changes: 17 additions & 0 deletions migrations/postgres/2019-12-10-104935_fill_timelines/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
INSERT INTO timeline (post_id, timeline_id)
SELECT posts.id,timeline_definition.id FROM posts,timeline_definition
WHERE timeline_definition.query = 'all';

INSERT INTO timeline (post_id, timeline_id)
SELECT posts.id,timeline_definition.id FROM posts,timeline_definition
INNER JOIN blogs ON posts.blog_id = blogs.id
INNER JOIN instances ON blogs.instance_id = instances.id
WHERE timeline_definition.query = 'local' and instances.local = true;

INSERT INTO timeline (post_id, timeline_id)
SELECT posts.id,timeline_definition.id FROM posts
INNER JOIN blog_authors ON posts.blog_id = blog_authors.blog_id
LEFT JOIN follows ON blog_authors.author_id = follows.following_id
INNER JOIN timeline_definition ON follows.follower_id = timeline_definition.user_id
or blog_authors.author_id = timeline_definition.user_id
WHERE timeline_definition.query LIKE 'followed or [%]';

This file was deleted.

10 changes: 0 additions & 10 deletions migrations/sqlite/2019-04-28-201506_create_tantivy_index/up.sql

This file was deleted.

21 changes: 5 additions & 16 deletions migrations/sqlite/2019-06-24-105533_use_timelines_for_feed/up.sql
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
-- Your SQL goes here
--#!|conn: &Connection, path: &Path| {
--#! super::timeline::Timeline::new_for_instance(conn, "Local feed".into(), "local".into()).expect("Local feed creation error");
--#! super::timeline::Timeline::new_for_instance(conn, "Federated feed".into(), "all".into()).expect("Federated feed creation error");
--#!
--#! for i in 0.. {
--#! if let Some(users) = super::users::User::get_local_page(conn, (i * 20, (i + 1) * 20)).ok().filter(|l| !l.is_empty()) {
--#! for u in users {
--#! super::timeline::Timeline::new_for_user(conn, u.id, "Your feed".into(), format!("followed or author in [ {} ]", u.fqn)).expect("User feed creation error");
--#! }
--#! } else {
--#! break;
--#! }
--#! }
--#!
--#! Ok(())
--#!}
INSERT INTO timeline_definition (name, query) VALUES
('Local feed', 'local'),
('Federated feed', 'all');
INSERT INTO timeline_definition (user_id,name,query)
select id,'Your feed','followed or ['||fqn||']' from users;
8 changes: 8 additions & 0 deletions migrations/sqlite/2019-12-10-104935_fill_timelines/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DELETE FROM timeline WHERE id IN
(
SELECT timeline.id FROM timeline
INNER JOIN timeline_definition ON timeline.timeline_id = timeline_definition.id
WHERE timeline_definition.query LIKE 'followed or [%]' OR
timeline_definition.query = 'local' OR
timeline_definition.query = 'all'
);
17 changes: 17 additions & 0 deletions migrations/sqlite/2019-12-10-104935_fill_timelines/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
INSERT INTO timeline (post_id, timeline_id)
SELECT posts.id,timeline_definition.id FROM posts,timeline_definition
WHERE timeline_definition.query = 'all';

INSERT INTO timeline (post_id, timeline_id)
SELECT posts.id,timeline_definition.id FROM posts,timeline_definition
INNER JOIN blogs ON posts.blog_id = blogs.id
INNER JOIN instances ON blogs.instance_id = instances.id
WHERE timeline_definition.query = 'local' and instances.local = true;

INSERT INTO timeline (post_id, timeline_id)
SELECT posts.id,timeline_definition.id FROM posts
INNER JOIN blog_authors ON posts.blog_id = blog_authors.blog_id
LEFT JOIN follows ON blog_authors.author_id = follows.following_id
INNER JOIN timeline_definition ON follows.follower_id = timeline_definition.user_id
or blog_authors.author_id = timeline_definition.user_id
WHERE timeline_definition.query LIKE 'followed or [%]';