Postgresql
Created by: zzet
What about this solution?
- After patch AR Postgres users nothing to lose, since Postgres is no limited the :text column type. Now we can safely eat from schema.rb which was generated for mysql
- Added support for using string FK with integer PK
That's all.
Merge request reports
Activity
214 $ su - gitlab 215 $ psql -d gitlabhq_production -U gitlab 216 217 # Exit PostgreSQL Server and copy the example config, make sure to update username/password in config/database.yml 218 sudo -u gitlab cp config/database.yml.postgres config/database.yml 219 220 # If you need create development, test, staging or another database 221 # Repeate some steps with actual commands 222 191 223 #### Install gems 192 224 193 sudo -u gitlab -H bundle install --without development test --deployment 225 # Please, check Gemfile before run bundle install 226 # Select database gem, wich you will use 227 # or run to setup gems with mysql usage 228 sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment 214 $ su - gitlab 215 $ psql -d gitlabhq_production -U gitlab 216 217 # Exit PostgreSQL Server and copy the example config, make sure to update username/password in config/database.yml 218 sudo -u gitlab cp config/database.yml.postgres config/database.yml 219 220 # If you need create development, test, staging or another database 221 # Repeate some steps with actual commands 222 191 223 #### Install gems 192 224 193 sudo -u gitlab -H bundle install --without development test --deployment 225 # Please, check Gemfile before run bundle install 226 # Select database gem, wich you will use 227 # or run to setup gems with mysql usage 228 sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment Created by: dzaporozhets
@zzet :) или по русски "улыбочка"
By Administrator on 2012-10-10T11:54:54 (imported from GitLab project)
By Administrator on 2012-10-10T11:54:54 (imported from GitLab)
1 class PostgresCreateIntegerCast < ActiveRecord::Migration 2 def up 3 execute <<-SQL 4 CREATE CAST (integer AS text) WITH INOUT AS IMPLICIT; 1 class PostgresCreateIntegerCast < ActiveRecord::Migration 2 def up 3 execute <<-SQL 4 CREATE CAST (integer AS text) WITH INOUT AS IMPLICIT; Created by: dmke
No,
INOUT
is correct (cf. docs):Parameters
WITH INOUT
Indicates that the cast is an I/O conversion cast, performed by invoking the output function of the source data type, and passing the resulting string to the input function of the target data type.By Administrator on 2012-10-11T22:17:05 (imported from GitLab project)
By Administrator on 2012-10-11T22:17:05 (imported from GitLab)
Created by: jirutka
These are basically the same fixes proposed in #554 (closed) which were rejected as “hacks”…
There’s still the same issue with the CAST of integer – you need admin rights in PostgreSQL (user “postgres” by default) to do that and it’s not propagated (and can not be) to schema.rb so you have to run migrations to apply it (
rake gitlab:app:setup
is not sufficient). However, this solution works, I’m using it as well, but it’s not nice at all. It should be noted that it’s a bug in ARel / Rails with polymorphic associations which causes this problem.There’s still the issue with wiki pages I’ve described in #1489 which you didn’t respond to. You also should know that this functionality is not covered by tests, that’s why it seems to be ok now…
I’m also very unhappy with your final answer to #554 (closed) – this is not about “hacking” GitLab to work on PostgreSQL but fixing it to work on any proper SQL database! It’s simply broken and it works on MySQL and SQLite just because it violates SQL standard. However, this is mainly ARel’s fault, not GitLab’s.
Sorry, this kinda raised my blood pressure this morning.
By Administrator on 2012-10-12T12:10:22 (imported from GitLab project)
By Administrator on 2012-10-12T12:10:22 (imported from GitLab)
Created by: zzet
As @jirutka said:
It should be noted that it’s a bug in ARel / Rails with polymorphic associations which causes this problem.
Do you know, what one developer make PR to Rails with fix this bug?
I'm control this moment.
As @jirutka said:
There’s still the same issue with the CAST of integer – you need admin rights in PostgreSQL (user “postgres” by default) to do that
Administrator rights are not required to do so, if you implement a function for conversion.
As @jirutka said:
and it’s not propaged (and can not be) to schema.rb so you have to run migrations to apply it
Bad solution... Zero migration may be, but not run migration.
As @jirutka said:
There’s still the issue with wiki pages I’ve described in #1489 which you didn’t respond to. You also should know that this funcionality is not covered by tests, that’s why it seems to be ok now…
I think, that some messages not to public publications
As @jirutka said:
I’m also very unhappy with your final answer to #554 (closed) – this is not about “hacking” GitLab to work on PostgreSQL but fixing it to work on any proper SQL database! It’s simply broken and it works on MySQL and SQLite just because it violates SQL standard. However, this is mainly ARel’s fault, not GitLab’s.
This is the best solution that can be used at this time. What about other databases - what exactly are you talking about? Or are you just the way you wrote? Let's be objective. This pull solves the problem of compatibility for Postgres and destroys what was now. Our team understands that this is not the best solution of those that can be and we do Research, on this issue, as you can support 3 of DBMSs such hacks. AR will patch up until not fix a bug in the rails that on CAST - it is a disgusting decision, I was disgusted by it, but what do you suggest?
For the future - in Russia there is a saying. "Criticize - offer. Suggest - do."
When we needed support Postgres - we had a discussion with a dense Gitlab developers on the issue and found a common ground. You tried to understand them and understand what they do not like?
thx
By Administrator on 2012-10-12T12:14:44 (imported from GitLab project)
By Administrator on 2012-10-12T12:14:44 (imported from GitLab)
1 class PostgresCreateIntegerCast < ActiveRecord::Migration 2 def up 3 execute <<-SQL 4 CREATE CAST (integer AS text) WITH INOUT AS IMPLICIT; Created by: zzet
@vsizov this solution not good, but it is better, what we can do at this moment.
INOUT - correct, but needed with super user. For many other solutions - it's awful, but it is normal for Gitlab as the decision itself - the product and the infrastructure is controlled by administrators.
@dmke thanks for answer
By Administrator on 2012-10-12T12:25:10 (imported from GitLab project)
By Administrator on 2012-10-12T12:25:10 (imported from GitLab)
Created by: williscool
So the cast migration didn't work for me
but logging in with
RAILS_ENV=production rails db
can then running that cast
CREATE CAST (integer AS text) WITH INOUT AS IMPLICIT;
did
By Administrator on 2012-10-27T16:54:22 (imported from GitLab project)
By Administrator on 2012-10-27T16:54:22 (imported from GitLab)
Created by: zzet
@williscool you read https://github.com/gitlabhq/gitlabhq/pull/1666#issuecomment-9374548 tred?
currently required to use Postgres superuser
By Administrator on 2012-10-27T08:27:52 (imported from GitLab project)
By Administrator on 2012-10-27T08:27:52 (imported from GitLab)
Created by: williscool
Yeah I did see that. Don't know that I knew exactly what it meant though.
But I'm debating in my head whether it would be better to not have that migration and just tell people to log into the console and do it.
I say this because I think the migrations are rolling back because this fails. And it would be easier to make sure that doesn't happens and then do the type cast yourself as that user.
Kind of like a final Warning: postgres support is experimental at this point
But of course:
- anyone technical enough to want to run postgres will figure it out anyway
- its up to you guys. This is a great product as is that you guys have done a tremendous job on and I'm happy to have
By Administrator on 2012-10-27T18:47:21 (imported from GitLab project)
By Administrator on 2012-10-27T18:47:21 (imported from GitLab)