Error when creating unaccent extension on PostgreSQL

You need to install the package postgresql-contrib-9.1 in your system first. (Adapt to your version number! Here is the currently available list of packages.) That’s the case under Debian, Ubuntu & friends anyway. Using a system user with the necessary privileges: apt-get install postgresql-contrib-9.1 If your currently logged in user does not have the necessary … Read more

Is there a “pg_restore –quiet” option like “psql –quiet”?

The question seems to imply that pg_restore is executing these SQL commands and you wouldn’t want to see them in the output. But outputting them is what it’s only supposed to do. pg_restore has two modes of operation, with or without connecting to a database. When it’s called without a database (-d option) as shown … Read more

Add primary key to PostgreSQL table only if it does not exist

You could do something like the following, however it is better to include it in the create table as a_horse_with_no_name suggests. if NOT exists (select constraint_name from information_schema.table_constraints where table_name=”table_name” and constraint_type=”PRIMARY KEY”) then ALTER TABLE table_name ADD PRIMARY KEY (id); end if;

What are the pros and cons for choosing a character varying data type for primary key in SQL? [closed]

The advantages you have for choosing a character datatype as a primary key field is that you may choose what data it can show. As an example, you could have the email address as the key field for a users table. The eliminates the need for an additional column. Another advantage is if you have … Read more

How to create a enum field with default value?

I was trying the same as you, and I got answer in stackoverflow only, It is possible to create ENUM with default value. Here is what I got for you. CREATE TYPE status AS ENUM (‘Notconfirmed’,’Coming’, ‘Notcoming’, ‘Maycome’); CREATE TABLE t ( id serial, s status default ‘Notconfirmed’ — <==== default value ); INSERT INTO … Read more

How to define and use JSON data type in Eloquent?

In your migrations you can do something like: $table->json(‘field_name’); And in your model you add the field to the $casts property to instruct Eloquent to deserialize it from JSON into a PHP array: class SomeModel extends Model { protected $casts = [ ‘field_name’ => ‘array’ ]; } Source: https://laravel.com/docs/5.1/eloquent-mutators#attribute-casting Note: This is also relevant answer … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)