def create_notifications(apps, schema_editor): update_all_contenttypes(verbosity=0) sql=""" INSERT INTO notifications_watched (object_id, created_date, content_type_id, user_id, project_id) SELECT userstory_id AS object_id, now() AS created_date, {content_type_id} AS content_type_id, user_id, project_id FROM userstories_userstory_watchers INNER JOIN userstories_userstory ON userstories_userstory_watchers.userstory_id = userstories_userstory.id""".format(content_type_id=ContentType.objects.get(model='userstory').id) cursor = connection.cursor() cursor.execute(sql)
def create_notifications(apps, schema_editor): update_all_contenttypes(verbosity=0) sql=""" INSERT INTO notifications_watched (object_id, created_date, content_type_id, user_id, project_id) SELECT milestone_id AS object_id, now() AS created_date, {content_type_id} AS content_type_id, user_id, project_id FROM milestones_milestone_watchers INNER JOIN milestones_milestone ON milestones_milestone_watchers.milestone_id = milestones_milestone.id""".format(content_type_id=ContentType.objects.get(model='milestone').id) cursor = connection.cursor() cursor.execute(sql)
def create_notifications(apps, schema_editor): update_all_contenttypes(verbosity=0) sql = """ INSERT INTO notifications_watched (object_id, created_date, content_type_id, user_id, project_id) SELECT task_id AS object_id, now() AS created_date, {content_type_id} AS content_type_id, user_id, project_id FROM tasks_task_watchers INNER JOIN tasks_task ON tasks_task_watchers.task_id = tasks_task.id""".format( content_type_id=ContentType.objects.get(model="task").id) cursor = connection.cursor() cursor.execute(sql)
def create_notifications(apps, schema_editor): update_all_contenttypes(verbosity=0) sql = """ INSERT INTO notifications_watched (object_id, created_date, content_type_id, user_id, project_id) SELECT wikipage_id AS object_id, now() AS created_date, {content_type_id} AS content_type_id, user_id, project_id FROM wiki_wikipage_watchers INNER JOIN wiki_wikipage ON wiki_wikipage_watchers.wikipage_id = wiki_wikipage.id""".format( content_type_id=ContentType.objects.get(model="wikipage").id ) cursor = connection.cursor() cursor.execute(sql)