     fun.(repo, path, file, name)
     Map.put(config, :timestamp, timestamp + 1)
   end
+
+  defp gen_table_statement(table_name) do
+    if use_binary_id?() do
+      """
+      create table(:#{table_name}, primary_key: false) do
+            add :id, :binary_id, primary_key: true
+      """
+    else
+      """
+      create table(:#{table_name}) do
+      """
+    end
+  end
+
+  defp gen_reference(table_name) do
+    type_hint = if use_binary_id?(), do: ", type: :binary_id", else: ""
+    "references(:#{table_name}, on_delete: :delete_all#{type_hint})"
+  end
+
+  defp use_binary_id?, do: !!Application.get_env(:phoenix, :generators)[:binary_id]
 
   ################
   # Web

        |> Enum.map(&("    " <> &1))
        |> Enum.join("\n")

      change = """
          #{verb} table(:#{table_name}) do
      #{adds}
          end
      #{constraints}

    table_name = config[:user_table_name]
    do_gen_migration config, "create_coherence_trackable", fn repo, _path, file, name ->
      change = """
          #{gen_table_statement(:trackables)}
            add :action, :string
            add :sign_in_count, :integer, default: 0
            add :current_sign_in_at, :utc_datetime
            add :last_sign_in_at, :utc_datetime
            add :current_sign_in_ip, :string
            add :last_sign_in_ip, :string
            add :user_id, #{gen_reference(table_name)}

            timestamps
          end
