Yii Framework Forum: Alternar Esquema Do Banco De Dados Postgresql Com Initsqls - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Alternar Esquema Do Banco De Dados Postgresql Com Initsqls Rate Topic: -----

#1 User is offline   Rafae 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 22-March 13

Posted 22 April 2013 - 09:55 AM

CREATE SEQUENCE usuario_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

CREATE TABLE "tb_usuario" (
"id" int4 DEFAULT nextval('usuario_id_seq'::regclass) NOT NULL,
"email" varchar(80) NOT NULL,
"senha" varchar(100) NOT NULL,
"ativo" int2 DEFAULT 0 NOT NULL,
"created_at" timestamp(6) DEFAULT now() NOT NULL,
"updated_at" timestamp(6) DEFAULT now() NOT NULL
)
WITH (OIDS=FALSE);

//config/main.php
  'db' => array(
            'connectionString' => 'pgsql:host=localhost;dbname=test',
            'emulatePrepare' => TRUE,
            'username' => 'user',
            'password' => 'pass',
            'charset' => 'utf8',
            'enableProfiling' => TRUE,
            'enableParamLogging' => TRUE,
            'tablePrefix' => 'tb_',
            "initSQLs" => array("SET search_path TO dev") # não funciona
        ),

class Usuario extends CActiveRecord
{ 

    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    public function tableName()
    {
        # só detecta a tabela usuario no schema dev desta forma
        return "dev.tb_usuario";
    }
}

Como faço para que o Yii detecte a tabela tb_usuario sem essa gambiarra?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users