defmodule OhMyExOhIrcd.Repo.Migrations.CreateShortLinks do
use Ecto.Migration
# Oper-managed URL shortener. A short `/s/<slug>` redirects to `url`.
# `click_count`/`last_clicked_at` are denormalized counters bumped on each
# hit so the admin list is cheap; per-click rows (with referrer/UA) live in
# `short_link_clicks` for detailed metrics.
def change do
create table(:short_links) do
add :slug, :string, null: false
add :url, :text, null: false
add :title, :string
add :created_by_user_id, references(:users, on_delete: :nilify_all)
add :click_count, :bigint, null: false, default: 0
add :last_clicked_at, :utc_datetime
timestamps(type: :utc_datetime)
end
create unique_index(:short_links, [:slug])
end
end
neiam
/oh-my-ex-oh-ircd
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
781 B · text
History
4b6fe3b