Upload of project source code files.

This commit is contained in:
2026-02-17 03:56:54 +01:00
parent 2dded110c8
commit ed6df5efbe
70 changed files with 12395 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
[
import_deps: [:ecto_sql],
inputs: ["*.exs"]
]

View File

@@ -0,0 +1,18 @@
defmodule Vishnya.Repo.Migrations.CreateUsers do
use Ecto.Migration
def change do
create table(:users) do
add :username, :string, null: false, size: 12
add :password_hash, :string, null: false
add :user_id, :string, null: false, size: 18
add :token, :string, null: false
timestamps()
end
create unique_index(:users, [:username])
create unique_index(:users, [:user_id])
create unique_index(:users, [:token])
end
end

View File

@@ -0,0 +1,22 @@
defmodule Vishnya.Repo.Migrations.CreateDiscordUsers do
use Ecto.Migration
def change do
create table(:discord_users) do
add :user_id, :bigint
add :username, :string
add :discriminator, :string
add :profile_picture, :string
add :bio, :text
add :pronouns, :string
add :status, :string
add :banner_color, :string
add :has_nitro, :boolean
add :badges, {:array, :string}
timestamps()
end
create unique_index(:discord_users, [:user_id])
end
end

View File

@@ -0,0 +1,19 @@
defmodule Vishnya.Repo.Migrations.CreateDiscordServers do
use Ecto.Migration
def change do
create table(:servers) do
add :server_id, :bigint
add :server_name, :string
add :member_count, :integer
add :invite_links, {:array, :string}
add :vanity_url, :string
add :banner_url, :string
add :created_at, :utc_datetime
timestamps()
end
create unique_index(:servers, [:server_id])
end
end

View File

@@ -0,0 +1,18 @@
defmodule Vishnya.Repo.Migrations.CreateDiscordChannels do
use Ecto.Migration
def change do
create table(:channels) do
add :channel_id, :bigint
add :server_id, references(:servers, column: :server_id, type: :bigint)
add :channel_name, :string
add :description, :text
add :type, :string # e.g., "text", "voice", etc.
add :created_at, :utc_datetime
timestamps()
end
create index(:channels, [:channel_id])
end
end

View File

@@ -0,0 +1,20 @@
defmodule Vishnya.Repo.Migrations.CreateDiscordMessages do
use Ecto.Migration
def change do
create table(:messages) do
add :message_id, :bigint
add :user_id, references(:discord_users, column: :user_id, type: :bigint)
add :channel_id, references(:channels, column: :id, type: :bigint)
add :server_id, references(:servers, column: :id, type: :bigint)
add :content, :text
add :attachments, {:array, :string}
add :type, :string
add :sent_at, :utc_datetime
timestamps()
end
create unique_index(:messages, [:message_id])
end
end

View File

@@ -0,0 +1,20 @@
defmodule Vishnya.Repo.Migrations.CreateDiscordMessageChangeLogs do
use Ecto.Migration
def change do
create table(:message_change_logs) do
add :message_id, references(:messages, type: :bigint, on_delete: :delete_all)
add :user_id, references(:discord_users, column: :user_id, type: :bigint)
add :channel_id, references(:channels, column: :id, type: :bigint)
add :server_id, references(:servers, column: :id, type: :bigint)
add :content, :text
add :attachments, {:array, :string}
add :type, :string
add :change_timestamp, :utc_datetime
timestamps()
end
create unique_index(:message_change_logs, [:message_id, :change_timestamp])
end
end

View File

@@ -0,0 +1,19 @@
defmodule Vishnya.Repo.Migrations.CreateDiscordServerChangeLogs do
use Ecto.Migration
def change do
create table(:server_change_logs) do
add :server_id, references(:servers, column: :id, type: :bigint)
add :server_name, :string
add :member_count, :integer
add :invite_links, {:array, :string}
add :vanity_url, :string
add :banner_url, :string
add :change_timestamp, :utc_datetime
timestamps()
end
create unique_index(:server_change_logs, [:server_id, :change_timestamp])
end
end

View File

@@ -0,0 +1,23 @@
defmodule Vishnya.Repo.Migrations.CreateDiscordUserChangeLogs do
use Ecto.Migration
def change do
create table(:user_change_logs) do
add :user_id, references(:discord_users, column: :user_id, type: :bigint)
add :username, :string
add :discriminator, :string
add :profile_picture, :string
add :bio, :text
add :pronouns, :string
add :status, :string
add :banner_color, :string
add :has_nitro, :boolean
add :badges, {:array, :string}
add :change_timestamp, :utc_datetime
timestamps()
end
create unique_index(:user_change_logs, [:user_id, :change_timestamp])
end
end

View File

@@ -0,0 +1,18 @@
defmodule Vishnya.Repo.Migrations.CreateDiscordChannelChangeLogs do
use Ecto.Migration
def change do
create table(:channel_change_logs) do
add :channel_id, references(:channels, column: :id, type: :bigint)
add :server_id, references(:servers, column: :id, type: :bigint)
add :channel_name, :string
add :description, :text
add :type, :string
add :change_timestamp, :utc_datetime
timestamps()
end
create unique_index(:channel_change_logs, [:channel_id, :change_timestamp])
end
end

11
priv/repo/seeds.exs Normal file
View File

@@ -0,0 +1,11 @@
# Script for populating the database. You can run it as:
#
# mix run priv/repo/seeds.exs
#
# Inside the script, you can read and write to any of your
# repositories directly:
#
# Vishnya.Repo.insert!(%Vishnya.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.