Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

434
Vistas
Modify schema name of postgresql db from "public" to "my-project"

I use ActiveRecord to migrate the changes to postgresql db. The schema name by default is "public". Where is the best way to rename this to "my-project-name".?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

There is no such method in ActiveRecord::Migration to alter scheme name, but you able to use plain sql command.

First generate migration file:

$> bundle exec rails g migration RenameSchema

Then open it and add:

class RenameSchema < ActiveRecord::Migration
  def up
    execute "ALTER SCHEMA you_old_name RENAME TO you_new_name" 
  end

  def down
    execute "ALTER SCHEMA you_new_name RENAME TO you_old_name" 
  end
end

With that migration you can change name and rollback it back.

Note: You must own the schema to use ALTER SCHEMA. To rename a schema you must also have the CREATE privilege for the database.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda