Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yahor opened this issue Apr 24, 2022 · 7 comments
Open

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

yahor opened this issue Apr 24, 2022 · 7 comments

Comments

@yahor
Copy link
Contributor

yahor commented Apr 24, 2022

Каб не было праблем з схемай пасля пракаткі міграцыі ў 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
@yahor yahor changed the title Перасці на PostgreSQL у development Перайсці на PostgreSQL у development Apr 25, 2022
@abitrolly
Copy link
Member

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

@yahor
Copy link
Contributor Author

yahor commented Apr 25, 2022

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

@jekhor
Copy link
Member

jekhor commented Apr 25, 2022

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

@jekhor
Copy link
Member

jekhor commented Apr 25, 2022

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

@yahor
Copy link
Contributor Author

yahor commented Apr 25, 2022

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

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

@jekhor
Copy link
Member

jekhor commented Apr 26, 2022

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

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

@abitrolly
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants