     |> (fn(name) -> "/tmp/test_" <> name <> ".db" end).()
   end
 
-  import Ecto.Migration, only: [table: 1, table: 2, index: 2, index: 3, references: 1, references: 2]
-
-  test "executing a string during migration" do
-    assert SQL.execute_ddl("example") == "example"
-  end
-
-  test "create table" do
-    create = {:create, table(:posts),
-               [{:add, :name, :string, [default: "Untitled", size: 20, null: false]},
-                {:add, :price, :numeric, [precision: 8, scale: 2, default: {:fragment, "expr"}]},
-                {:add, :on_hand, :integer, [default: 0, null: true]},
-                {:add, :is_active, :boolean, [default: true]}]}
-    query = SQL.execute_ddl(create)
-    assert query == ~s{CREATE TABLE "posts" ("name" TEXT DEFAULT 'Untitled' NOT NULL, "price" NUMERIC DEFAULT (expr), "on_hand" INTEGER DEFAULT 0, "is_active" BOOLEAN DEFAULT 1)}
-  end
-
-  test "create table if not exists" do
-    create = {:create_if_not_exists, table(:posts),
-               [{:add, :id, :serial, [primary_key: true]},
-                {:add, :title, :string, []},
-                {:add, :price, :decimal, [precision: 10, scale: 2]},
-                {:add, :created_at, :datetime, []}]}
-    query = SQL.execute_ddl(create)
-    assert query == ~s{CREATE TABLE IF NOT EXISTS "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "title" TEXT, "price" DECIMAL(10,2), "created_at" DATETIME)}
-  end
-
-  test "create table with table options" do
-    create = {:create, table(:posts, options: "WITHOUT ROWID"),
-               [{:add, :id, :serial, [primary_key: true]},
-                {:add, :created_at, :datetime, []}]}
-    assert SQL.execute_ddl(create) == ~s{CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "created_at" DATETIME) WITHOUT ROWID}
-  end
-
-  test "create table with prefix" do
-    create = {:create, table(:posts, prefix: :foo),
-               [{:add, :name, :string, [default: "Untitled", size: 20, null: false]},
-                {:add, :price, :numeric, [precision: 8, scale: 2, default: {:fragment, "expr"}]},
-                {:add, :on_hand, :integer, [default: 0, null: true]},
-                {:add, :is_active, :boolean, [default: true]}]}
-
-    assert SQL.execute_ddl(create) == ~s{CREATE TABLE "foo"."posts" ("name" TEXT DEFAULT 'Untitled' NOT NULL, "price" NUMERIC DEFAULT (expr), "on_hand" INTEGER DEFAULT 0, "is_active" BOOLEAN DEFAULT 1)}
-  end
-
-  test "create table with references including prefixes" do
-    create = {:create, table(:posts, prefix: :foo),
-               [{:add, :id, :serial, [primary_key: true]},
-                {:add, :category_0, references(:categories, prefix: :foo), []},
-                {:add, :category_1, references(:categories, name: :foo_bar, prefix: :foo), []},
-                {:add, :category_2, references(:categories, on_delete: :nothing, prefix: :foo), []},
-                {:add, :category_3, references(:categories, on_delete: :delete_all, prefix: :foo), [null: false]},
-                {:add, :category_4, references(:categories, on_delete: :nilify_all, prefix: :foo), []}]}
-
-    assert SQL.execute_ddl(create) == ~s{CREATE TABLE "foo"."posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "category_0" CONSTRAINT "posts_category_0_fkey" REFERENCES "foo"."categories"("id"), "category_1" CONSTRAINT "foo_bar" REFERENCES "foo"."categories"("id"), "category_2" CONSTRAINT "posts_category_2_fkey" REFERENCES "foo"."categories"("id"), "category_3" NOT NULL CONSTRAINT "posts_category_3_fkey" REFERENCES "foo"."categories"("id") ON DELETE CASCADE, "category_4" CONSTRAINT "posts_category_4_fkey" REFERENCES "foo"."categories"("id") ON DELETE SET NULL)}
-  end
-
-  test "create table with references" do
-    create = {:create, table(:posts),
-               [{:add, :id, :serial, [primary_key: true]},
-                {:add, :category_0, references(:categories), []},
-                {:add, :category_1, references(:categories, name: :foo_bar), []},
-                {:add, :category_2, references(:categories, on_delete: :nothing), []},
-                {:add, :category_3, references(:categories, on_delete: :delete_all), [null: false]},
-                {:add, :category_4, references(:categories, on_delete: :nilify_all), []}]}
-
-    assert SQL.execute_ddl(create) == ~s{CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "category_0" CONSTRAINT "posts_category_0_fkey" REFERENCES "categories"("id"), "category_1" CONSTRAINT "foo_bar" REFERENCES "categories"("id"), "category_2" CONSTRAINT "posts_category_2_fkey" REFERENCES "categories"("id"), "category_3" NOT NULL CONSTRAINT "posts_category_3_fkey" REFERENCES "categories"("id") ON DELETE CASCADE, "category_4" CONSTRAINT "posts_category_4_fkey" REFERENCES "categories"("id") ON DELETE SET NULL)}
-  end
-
-  test "drop table" do
-    assert SQL.execute_ddl({:drop, %Table{name: "posts"}}) == ~s{DROP TABLE "posts"}
-  end
-
-  test "drop table if exists" do
-    assert SQL.execute_ddl({:drop_if_exists, %Table{name: "posts"}}) == ~s{DROP TABLE IF EXISTS "posts"}
-  end
-
-  test "drop table with prefixes" do
-    drop = {:drop, table(:posts, prefix: :foo)}
-    assert SQL.execute_ddl(drop) == ~s{DROP TABLE "foo"."posts"}
-  end
-
-  test "create index" do
-    create = {:create, index(:posts, [:category_id, :permalink])}
-    query = SQL.execute_ddl(create)
-    assert query == ~s{CREATE INDEX "posts_category_id_permalink_index" ON "posts" ("category_id", "permalink")}
-  end
-
-  test "create index if not exists" do
-    create = {:create_if_not_exists, index(:posts, [:category_id, :permalink])}
-    query = SQL.execute_ddl(create)
-    assert query == ~s{CREATE INDEX IF NOT EXISTS "posts_category_id_permalink_index" ON "posts" ("category_id", "permalink")}
-  end
-
-  test "create index with prefix" do
-    create = {:create, index(:posts, [:category_id, :permalink], prefix: :foo)}
-    assert SQL.execute_ddl(create) == ~s{CREATE INDEX "posts_category_id_permalink_index" ON "foo"."posts" ("category_id", "permalink")}
-  end
-
-  test "create unique index" do
-    create = {:create, index(:posts, [:permalink], unique: true)}
-    query = SQL.execute_ddl(create)
-    assert query == ~s{CREATE UNIQUE INDEX "posts_permalink_index" ON "posts" ("permalink")}
-  end
-
-  test "create unique index if not exists" do
-    create = {:create_if_not_exists, index(:posts, [:permalink], unique: true)}
-    query = SQL.execute_ddl(create)
-    assert query == ~s{CREATE UNIQUE INDEX IF NOT EXISTS "posts_permalink_index" ON "posts" ("permalink")}
-  end
-
-  test "drop index" do
-    drop = {:drop, index(:posts, [:id], name: "posts$main")}
-    assert SQL.execute_ddl(drop) == ~s{DROP INDEX "posts$main"}
-  end
-
-  test "drop index with prefix" do
-    drop = {:drop, index(:posts, [:id], name: "posts$main", prefix: :foo)}
-    assert SQL.execute_ddl(drop) == ~s{DROP INDEX "posts$main"}
-  end
-
-  test "drop index if exists" do
-    drop = {:drop_if_exists, index(:posts, [:id], name: "posts$main")}
-    assert SQL.execute_ddl(drop) == ~s{DROP INDEX IF EXISTS "posts$main"}
-  end
-
-  test "rename table" do
-    rename = {:rename, table(:posts), table(:new_posts)}
-    assert SQL.execute_ddl(rename) == ~s{ALTER TABLE "posts" RENAME TO "new_posts"}
-  end
-
-  test "rename table with prefix" do
-    rename = {:rename, table(:posts, prefix: :foo), table(:new_posts, prefix: :foo)}
-    assert SQL.execute_ddl(rename) == ~s{ALTER TABLE "foo"."posts" RENAME TO "foo"."new_posts"}
-  end
-
-  test "alter table" do
-    alter = {:alter, table(:posts),
-               [{:add, :title, :string, [default: "Untitled", size: 100, null: false]},
-                {:add, :author_id, references(:author), []}]}
-    query = SQL.execute_ddl(alter)
-    assert query == ~s{ALTER TABLE "posts" ADD COLUMN "title" TEXT DEFAULT 'Untitled' NOT NULL; ALTER TABLE "posts" ADD COLUMN "author_id" CONSTRAINT "posts_author_id_fkey" REFERENCES "author"("id")}
-  end
-
-  test "alter table with prefix" do
-    alter = {:alter, table(:posts, prefix: :foo),
-               [{:add, :title, :string, [default: "Untitled", size: 100, null: false]},
-                {:add, :author_id, references(:author, prefix: :foo), []}]}
-
-    assert SQL.execute_ddl(alter) == ~s{ALTER TABLE "foo"."posts" ADD COLUMN "title" TEXT DEFAULT 'Untitled' NOT NULL; ALTER TABLE "foo"."posts" ADD COLUMN "author_id" CONSTRAINT "posts_author_id_fkey" REFERENCES "foo"."author"("id")}
-  end
-
-  test "alter column errors" do
-    alter = {:alter, table(:posts), [{:modify, :price, :numeric, [precision: 8, scale: 2]}]}
-    assert_raise ArgumentError, "ALTER COLUMN not supported by SQLite", fn ->
-      SQL.execute_ddl(alter)
-    end
-  end
-
-  test "rename column errors" do
-    rename = {:rename, table(:posts), :given_name, :first_name}
-    assert_raise ArgumentError, "RENAME COLUMN not supported by SQLite", fn ->
-      SQL.execute_ddl(rename)
-    end
-  end
-
-  test "drop column errors" do
-    alter = {:alter, table(:posts), [{:remove, :summary}]}
-    assert_raise ArgumentError, "DROP COLUMN not supported by SQLite", fn ->
-      SQL.execute_ddl(alter)
-    end
-  end
-
   ## Tests stolen from PostgreSQL adapter:
 
   import Ecto.Query

    query = SQL.delete("prefix", "model", [:x, :y], [])
    assert query == ~s{DELETE FROM "prefix"."model" WHERE "x" = ?1 AND "y" = ?2}
  end
end

    assert SQL.all(query) == ~s{SELECT m0."x" FROM "model" AS m0}
  end

  test "from without schema" do
    query = "posts" |> select([r], r.x) |> normalize
    assert SQL.all(query) == ~s{SELECT p0."x" FROM "posts" AS p0}

