minsk-hackerspace / hackerspace.by

Website of Minsk Hackerspace (Ruby on Rails)
https://hackerspace.by/
11 stars 20 forks source link

Перайсці на PostgreSQL у development #545

Open yahor opened 2 years ago

yahor commented 2 years ago

Каб не было праблем з схемай пасля пракаткі міграцыі ў development прапаную SQLlite замфніць на PostgreSQL.

_Primary keys - By default, Active Record will use an integer column named id as the table's primary key (bigint for PostgreSQL and MySQL, integer for SQLite). When using Active Record Migrations to create your tables, this column will be automatically created._

$ git diff db/schema.rb
diff --git a/db/schema.rb b/db/schema.rb
index 8ff8a3f..aa3a884 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -34,7 +34,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_04_23_224009) do
   end

   create_table "active_storage_variant_records", force: :cascade do |t|
-    t.bigint "blob_id", null: false
+    t.integer "blob_id", null: false
     t.string "variation_digest", null: false
     t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
   end
abitrolly commented 2 years ago

А какие проблемы конкретнее? ORM же всё автоматом разруливает.

yahor commented 2 years ago

@abitrolly я ж напісаў вышэй у чым праблема. кожны раз ревертаць integer/bigint

jekhor commented 2 years ago

Не зразумеў, што куды навошта рэвертаць?

jekhor commented 2 years ago

Ну integer ды integer, дзе гэта праблему стварае?

yahor commented 2 years ago

Ну па пунктах:

  1. Лепш мець аднольавы стэк бо SQLite ўрэзаны ў плане магчымасцяў
  2. Девелапер дадае табліцу і думае, чаму схема памянялася там дзе девелапер код не чапаў. А гэта праблема базы.
jekhor commented 2 years ago

А чаму яна будзе мяняцца, калі ўсе дэвэлаперы карыстаюцца SQLite?

PostgreSQL складана наладжваць, таму лепш пакінуць SQLite. Некалі ўжо быў пастгрэс — адкацілі, бо нязручна.

abitrolly commented 2 years ago

@yahor напиши по пунктам, какая проблема где происходит. Я не понимаю. Ты делаешь новую миграцию на свой машине. В ней в качестве типа для поля id стоит integer. И что дальше происходит?