You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: m20221210_000001_add_crawl_tags_table.rs
    path of file: ./repos/spyglass/crates/migrations/src
    
    the code of the file until where you have to start completion: use entities::{
    models::{
        crawl_queue, crawl_tag, lens,
        tag::{get_or_create, TagType},
    },
    sea_orm::{
        ColumnTrait, ConnectionTrait, DatabaseTransaction, DbBackend, EntityTrait, QueryFilter,
        Set, Statement, TransactionTrait,
    },
    BATCH_SIZE,
};
use sea_orm_migration::prelude::*;
use shared::config::{Config, LensConfig};
use std::time::Instant;

pub struct Migration;

impl MigrationName for Migration {
    fn name(&self) -> &str {
        "m20221210_000001_add_crawl_tags_table"
    }
}

async fn add_tags_for_url<C>(tx: &C, name: &str, url: &str) -> Result<(), DbErr>
where
    C: ConnectionTrait,
{
    // Igno
    
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        if manager.get_database_backend() == DbBackend::Sqlite {
            // Add crawl_tag table & idx
            manager
                .get_connection()
                .execute(Statement::from_string(
                    manager.get_database_backend(),
                    r#"CREATE TABLE IF NOT EXISTS "crawl_tag" (
                    "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
                    "crawl_queue_id" integer NOT NULL,
                    "tag_id" integer NOT NULL,
                    "created_at" text NOT NULL,
                    "updated_at" text NOT NULL,
                    FOREIGN KEY(crawl_queue_id) REFERENCES crawl_queue(id),
                    FOREIGN KEY(tag_id)         REFERENCES tags(id)
                );"#
                    .to_string(),
                ))
                .await?;
        } else if manager.get_database_backend() == DbBackend::Postgres {
            // Add crawl_tag table & idx
            manager
                .get_connection()
                .execute(Statement::from_string(
                    manager.get_database_backend(),
                    r#"CREATE TABLE IF NOT EXISTS "crawl_tag" (
                    "id" BIGSERIAL PRIMARY KEY,
                    "crawl_queue_id" integer NOT NULL,
                    "tag_id" integer NOT NULL,
                    "created_at" TIMESTAMPTZ NOT NULL,
                    "updated_at" TIMESTAMPTZ NOT NULL,
                    CONSTRAINT fk_crawl_queue_id
                            FOREIGN KEY(crawl_queue_id)
                                REFERENCES crawl_queue(id),
                    CONSTRAINT fk_tag_id
                            FOREIGN KEY(tag_id)
                                REFERENCES tags(id)
                );"#
                    .to_string(),
                ))
                .await?;
        }

        manager
            .get_connection()
            .execute(Statement::from_string(
                manager.get_database_backend(),
                "CREATE UNIQUE INDEX IF NOT EXISTS \"idx-crawl-tag-doc-id-tag-id\" ON \"crawl_tag\" (\"crawl_queue_id\", \"tag_id\");"
                    .to_string(),
            ))
            .await?;

        let config = Config::new();
        let db = manager.get_connection();

        // Loop through lenses
        let lenses = lens::get_lens_names(db).await?;

        let lens_dir = config.lenses_dir();

        log::debug!("Loading lenses from {:?}", config.lenses_dir());
        for lens in lenses {
            let lens_path = lens_dir.join(format!("{}.ron", lens.name));
            if lens_path.exists() {
                match LensConfig::from_path(lens_path) {
                    Ok(lens_config) => {
                        let txn = db.begin().await?;
                        add_tags_for_lens(&txn, &lens_config).await;
                        txn.commit().await?;
                    }
                    Err(err) => log::error!("Unable to read lens: {}", err),
                }
            }
        }

        // Handle local files
        if let Err(err) = add_tags_for_url(db, "files", "file://").await {
            log::error!("Unable to add tags for file:// urls: {}", err);
        }

        Ok(())
    }