new_contents: # Generated by Django 2.1.11 on 2019-08-07 21:43
  
  from django.db import migrations
  
  FORWARDS = [
      """DROP TABLE piece_search""",
      """
      CREATE VIRTUAL TABLE piece_search
      USING fts5 (id unindexed, body, tokenize = 'porter unicode61')
      """,
      """
      CREATE TRIGGER library_piece_search_insert
      AFTER INSERT ON library_piece
      FOR EACH ROW
      BEGIN
          INSERT INTO piece_search (id, body)
          VALUES (NEW.id, NEW.title || ' ' || NEW.subtitle || ' ' || NEW.comment);
      END
      """,
      """
      INSERT INTO piece_search
                  (id, body)
           SELECT piece.id AS id,
                  piece.title || ' ' ||
                  piece.subtitle || ' ' ||
                  piece.comment || ' ' ||
                  COALESCE(GROUP_CONCAT(composer.given_names || ' ' || composer.surname), '') || ' ' ||
                  COALESCE(GROUP_CONCAT(arranger.given_names || ' ' || arranger.surname), '') AS body
             FROM library_piece AS piece
        LEFT JOIN library_piece_composer_artists AS pc ON piece.id = pc.piece_id
        LEFT JOIN library_piece_arranger_artists AS pa ON piece.id = pa.piece_id
        LEFT JOIN library_artist AS composer ON pc.artist_id = composer.id
        LEFT JOIN library_artist AS arranger ON pa.artist_id = arranger.id
         GROUP BY piece.id
      """,
  ]
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('library', '0012_fix_fts_delete'),
      ]
  
  
      operations = [
      ]
  
subject: Update sqlite fts to fts5