defmodule Podbox.Repo.Migrations.CreatePodcastTables do @moduledoc """ Updates resources based on their most recent snapshots. This file was autogenerated with `mix ash_sqlite.generate_migrations` """ use Ecto.Migration def up do create table(:podcast_shows, primary_key: false) do add :feed_id, references(:podcast_feed, column: :id, name: "podcast_shows_feed_id_fkey", type: :uuid) add :updated_at, :utc_datetime_usec, null: false add :inserted_at, :utc_datetime_usec, null: false add :ttl, :bigint add :rating, :text add :cloud, :text add :docs, :text add :generator, :text add :last_build_date, :utc_datetime add :pub_date, :utc_datetime add :webmaster, :text add :managing_editor, :text add :copyright, :text add :language, :text add :description, :text, null: false add :link, :text, null: false add :title, :text, null: false add :id, :uuid, null: false, primary_key: true end create table(:podcast_show_categories, primary_key: false) do add :updated_at, :utc_datetime_usec, null: false add :inserted_at, :utc_datetime_usec, null: false add :domain, :citext add :name, :citext, null: false add :resource_id, references(:podcast_shows, column: :id, name: "podcast_show_categories_resource_id_fkey", type: :uuid ), null: false add :id, :uuid, null: false, primary_key: true end create unique_index(:podcast_show_categories, [:name], name: "podcast_show_categories_unique_name_index" ) create table(:podcast_images, primary_key: false) do add :show_id, references(:podcast_shows, column: :id, name: "podcast_images_show_id_fkey", type: :uuid ) add :updated_at, :utc_datetime_usec, null: false add :inserted_at, :utc_datetime_usec, null: false add :height, :bigint add :width, :bigint add :link, :text add :title, :text add :url, :text, null: false add :id, :uuid, null: false, primary_key: true end create unique_index(:podcast_images, [:show_id], name: "podcast_images_unique_by_show_index") create table(:podcast_feed, primary_key: false) do add :updated_at, :utc_datetime_usec, null: false add :inserted_at, :utc_datetime_usec, null: false add :refreshed_at, :utc_datetime add :uri, :text, null: false add :id, :uuid, null: false, primary_key: true end create unique_index(:podcast_shows, [:feed_id], name: "podcast_shows_unique_per_feed_index") create table(:podcast_episodes, primary_key: false) do add :show_id, references(:podcast_shows, column: :id, name: "podcast_episodes_show_id_fkey", type: :uuid ) add :updated_at, :utc_datetime_usec, null: false add :inserted_at, :utc_datetime_usec, null: false add :episode_type, :text add :season, :text add :episode, :text add :subtitle, :text add :order, :text add :closed_captioned?, :boolean add :explicit?, :boolean add :duration, :time add :image, :text add :content, :text add :pub_date, :utc_datetime add :guid, :text, null: false add :comments, :text add :author, :text add :description, :text add :link, :text add :title, :text add :id, :uuid, null: false, primary_key: true end create unique_index(:podcast_episodes, [:guid, :show_id], name: "podcast_episodes_unique_guid_per_show_index" ) create table(:podcast_episode_categories, primary_key: false) do add :updated_at, :utc_datetime_usec, null: false add :inserted_at, :utc_datetime_usec, null: false add :domain, :citext add :name, :citext, null: false add :resource_id, references(:podcast_episodes, column: :id, name: "podcast_episode_categories_resource_id_fkey", type: :uuid ), null: false add :id, :uuid, null: false, primary_key: true end create unique_index(:podcast_episode_categories, [:name], name: "podcast_episode_categories_unique_name_index" ) create table(:podcast_enclosures, primary_key: false) do add :episode_id, references(:podcast_episodes, column: :id, name: "podcast_enclosures_episode_id_fkey", type: :uuid ) add :updated_at, :utc_datetime_usec, null: false add :inserted_at, :utc_datetime_usec, null: false add :mime_type, :text, null: false add :length, :bigint, null: false add :url, :text, null: false add :id, :uuid, null: false, primary_key: true end create table(:podcast_asset_feeds, primary_key: false) do add :feed_id, references(:podcast_feed, column: :id, name: "podcast_asset_feeds_feed_id_fkey", type: :uuid ) add :asset_id, references(:download_assets, column: :id, name: "podcast_asset_feeds_asset_id_fkey", type: :uuid ) add :id, :uuid, null: false, primary_key: true end create table(:podcast_asset_enclosures, primary_key: false) do add :enclosure_id, references(:podcast_enclosures, column: :id, name: "podcast_asset_enclosures_enclosure_id_fkey", type: :uuid ) add :asset_id, references(:download_assets, column: :id, name: "podcast_asset_enclosures_asset_id_fkey", type: :uuid ) add :id, :uuid, null: false, primary_key: true end create table(:download_assets, primary_key: false) do add :updated_at, :utc_datetime_usec, null: false add :inserted_at, :utc_datetime_usec, null: false add :asset_type, :text, null: false add :headers, :map, null: false, default: %{} add :error_detail, :text add :content_type, :text add :transferred_bytes, :bigint add :total_bytes, :bigint add :remaining_retries, :bigint, null: false add :state, :text, null: false add :uri, :text, null: false add :id, :uuid, null: false, primary_key: true end end def down do drop table(:download_assets) drop constraint(:podcast_asset_enclosures, "podcast_asset_enclosures_asset_id_fkey") drop constraint(:podcast_asset_enclosures, "podcast_asset_enclosures_enclosure_id_fkey") drop table(:podcast_asset_enclosures) drop constraint(:podcast_asset_feeds, "podcast_asset_feeds_asset_id_fkey") drop constraint(:podcast_asset_feeds, "podcast_asset_feeds_feed_id_fkey") drop table(:podcast_asset_feeds) drop constraint(:podcast_enclosures, "podcast_enclosures_episode_id_fkey") drop table(:podcast_enclosures) drop_if_exists unique_index(:podcast_episode_categories, [:name], name: "podcast_episode_categories_unique_name_index" ) drop constraint(:podcast_episode_categories, "podcast_episode_categories_resource_id_fkey") drop table(:podcast_episode_categories) drop_if_exists unique_index(:podcast_episodes, [:guid, :show_id], name: "podcast_episodes_unique_guid_per_show_index" ) drop constraint(:podcast_episodes, "podcast_episodes_show_id_fkey") drop table(:podcast_episodes) drop_if_exists unique_index(:podcast_shows, [:feed_id], name: "podcast_shows_unique_per_feed_index" ) drop table(:podcast_feed) drop_if_exists unique_index(:podcast_images, [:show_id], name: "podcast_images_unique_by_show_index" ) drop constraint(:podcast_images, "podcast_images_show_id_fkey") drop table(:podcast_images) drop_if_exists unique_index(:podcast_show_categories, [:name], name: "podcast_show_categories_unique_name_index" ) drop constraint(:podcast_show_categories, "podcast_show_categories_resource_id_fkey") drop table(:podcast_show_categories) drop constraint(:podcast_shows, "podcast_shows_feed_id_fkey") drop table(:podcast_shows) end end