Add snowflake IDs
This commit is contained in:
parent
4a890a39f4
commit
44b484de21
24 changed files with 116 additions and 14 deletions
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateInstanceSettings do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:instance_settings) do
|
||||
create table(:instance_settings, primary_key: false) do
|
||||
add :id, :integer, primary_key: true
|
||||
add :name, :string, default: "Nulla", null: false
|
||||
add :description, :text, default: "Freedom Social Network", null: false
|
||||
add :domain, :string, default: "localhost", null: false
|
||||
|
@ -16,6 +17,8 @@ defmodule Nulla.Repo.Migrations.CreateInstanceSettings do
|
|||
timestamps()
|
||||
end
|
||||
|
||||
execute "ALTER TABLE instance_settings ADD CONSTRAINT single_row CHECK (id = 1);"
|
||||
|
||||
flush()
|
||||
|
||||
execute(fn ->
|
||||
|
@ -31,11 +34,11 @@ defmodule Nulla.Repo.Migrations.CreateInstanceSettings do
|
|||
|
||||
sql = """
|
||||
INSERT INTO instance_settings (
|
||||
name, description, domain, registration,
|
||||
id, name, description, domain, registration,
|
||||
max_characters, max_upload_size, api_offset,
|
||||
public_key, private_key, inserted_at, updated_at
|
||||
) VALUES (
|
||||
'Nulla', 'Freedom Social Network', '#{domain}', false,
|
||||
1, 'Nulla', 'Freedom Social Network', '#{domain}', false,
|
||||
5000, 50, 100,
|
||||
#{esc.(public_key)}, #{esc.(private_key)},
|
||||
'#{now}', '#{now}'
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateUsers do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:users) do
|
||||
create table(:users, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :username, :string, null: false, unique: true
|
||||
add :email, :string
|
||||
add :password, :string
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateNotes do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:notes) do
|
||||
create table(:notes, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :content, :text
|
||||
add :visibility, :string, default: "public"
|
||||
add :sensitive, :boolean, default: false
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateBookmarks do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:bookmarks) do
|
||||
create table(:bookmarks, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :url, :string
|
||||
add :user_id, references(:users, on_delete: :delete_all)
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateNotifications do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:notifications) do
|
||||
create table(:notifications, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
||||
add :actor_id, references(:users, on_delete: :nilify_all)
|
||||
add :type, :string, null: false
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateModerationLogs do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:moderation_logs) do
|
||||
create table(:moderation_logs, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :moderator_id, references(:users, on_delete: :nilify_all), null: false
|
||||
add :target_type, :string, null: false
|
||||
add :target_id, :string, null: false
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateHashtags do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:hashtags) do
|
||||
create table(:hashtags, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :tag, :string, null: false
|
||||
add :usage_count, :integer, default: 0, null: false
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateFollows do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:follows) do
|
||||
create table(:follows, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
||||
add :target_id, references(:users, on_delete: :delete_all), null: false
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateSessions do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:sessions) do
|
||||
create table(:sessions, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
||||
add :token, :string, null: false
|
||||
add :user_agent, :string
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateMediaAttachments do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:media_attachments) do
|
||||
create table(:media_attachments, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :note_id, references(:notes, on_delete: :delete_all), null: false
|
||||
add :file, :string, null: false
|
||||
add :mime_type, :string
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule Nulla.Repo.Migrations.CreateActivities do
|
|||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:activities) do
|
||||
create table(:activities, primary_key: false) do
|
||||
add :id, :bigint, primary_key: true
|
||||
add :type, :string, null: false
|
||||
add :actor, :string, null: false
|
||||
add :object, :map, null: false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue