feat: port basic functionality to elixir

This commit is contained in:
Schuwi
2025-09-14 12:19:44 +02:00
parent 0a6b7e08e2
commit 5e49cb79a0
14 changed files with 1405 additions and 14 deletions

View File

@@ -0,0 +1,16 @@
defmodule ComponentsElixir.Repo.Migrations.CreateCategories do
use Ecto.Migration
def change do
create table(:categories) do
add :name, :string, null: false
add :description, :text
add :parent_id, references(:categories, on_delete: :delete_all)
timestamps()
end
create index(:categories, [:parent_id])
create unique_index(:categories, [:name, :parent_id])
end
end

View File

@@ -0,0 +1,25 @@
defmodule ComponentsElixir.Repo.Migrations.CreateComponents do
use Ecto.Migration
def change do
create table(:components) do
add :name, :string, null: false
add :description, :text
add :keywords, :string
add :position, :string
add :count, :integer, default: 0
add :datasheet_url, :string
add :image_filename, :string
add :category_id, references(:categories, on_delete: :restrict), null: false
timestamps()
end
create index(:components, [:category_id])
create index(:components, [:name])
# Full-text search indexes for PostgreSQL
execute "CREATE INDEX components_search_idx ON components USING gin(to_tsvector('english', name || ' ' || coalesce(description, '') || ' ' || coalesce(keywords, '')))",
"DROP INDEX components_search_idx"
end
end