You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
현재 프로젝트에서 생성되는 데이터베이스에 대해 uuid 관련 extension을 설치할 수 있도록 해야 합니다.
관련 정보
PostgreSQL에서의 uuid
PostgreSQL은 uuid를 자동으로 생성하는 기능이 있습니다.
그리고 TypeORM에서 @PrimaryGeneratedColumn("uuid") 데코레이터를 사용하여 uuid를 primary key로 생성할 수 있습니다.
또한, @PrimaryGeneratedColumn("uuid")은 자동으로 생성하고 저장해줍니다.
단, 해당 데이터베이스에서 uuid 생성 함수를 호출하기 위해 관련 extension을 설치해야 합니다.
설치되어 있지 않다면 typeORM 실행시 다음과 같은 에러가 발생합니다.
[Nest] 41362 - 07/02/2021, 9:15:39 PM [ExceptionHandler] function uuid_generate_v4() does not exist +0ms
QueryFailedError: function uuid_generate_v4() does not exist
at new QueryFailedError (/goinfre/yshin/ft_transcendence/back/node_modules/typeorm/error/QueryFailedError.js:12:28)
at PostgresQueryRunner.<anonymous> (/goinfre/yshin/ft_transcendence/back/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:248:31)
at step (/goinfre/yshin/ft_transcendence/back/node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
at Object.throw (/goinfre/yshin/ft_transcendence/back/node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
at rejected (/goinfre/yshin/ft_transcendence/back/node_modules/typeorm/node_modules/tslib/tslib.js:115:69)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
extension 설치
extension 설치는 다음의 명령어로 psql 콘솔에서 수행합니다.
이때, 명령어를 실행하는 유저는 해당 데이터베이스에 대한 소유권을 가진 owner여야 합니다.
database=> CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION
database=> \df
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+--------------------+------------------+---------------------------+------
public | uuid_generate_v1 | uuid | | func
public | uuid_generate_v1mc | uuid | | func
public | uuid_generate_v3 | uuid | namespace uuid, name text | func
public | uuid_generate_v4 | uuid | | func
public | uuid_generate_v5 | uuid | namespace uuid, name text | func
public | uuid_nil | uuid | | func
public | uuid_ns_dns | uuid | | func
public | uuid_ns_oid | uuid | | func
public | uuid_ns_url | uuid | | func
public | uuid_ns_x500 | uuid | | func
(10 rows)
문제 사항
현재 프로젝트에서 생성되는 데이터베이스에 대해 uuid 관련 extension을 설치할 수 있도록 해야 합니다.
관련 정보
PostgreSQL에서의 uuid
PostgreSQL은 uuid를 자동으로 생성하는 기능이 있습니다.
그리고 TypeORM에서
@PrimaryGeneratedColumn("uuid")
데코레이터를 사용하여 uuid를 primary key로 생성할 수 있습니다.또한,
@PrimaryGeneratedColumn("uuid")
은 자동으로 생성하고 저장해줍니다.단, 해당 데이터베이스에서 uuid 생성 함수를 호출하기 위해 관련 extension을 설치해야 합니다.
설치되어 있지 않다면 typeORM 실행시 다음과 같은 에러가 발생합니다.
extension 설치
extension 설치는 다음의 명령어로 psql 콘솔에서 수행합니다.
이때, 명령어를 실행하는 유저는 해당 데이터베이스에 대한 소유권을 가진 owner여야 합니다.
데이터베이스 소유자 변경
데이터베이스에 대한 소유자를 변경하는 명령어는 다음과 같습니다.
The text was updated successfully, but these errors were encountered: