Skip to content

Column is always integer when running npm run migrate #2398

@dhmlau

Description

@dhmlau

Description / Steps to reproduce / Feature proposal

I have a model property of type string. After running npm run migrate, the table gets created, and the type shows integer.

  • I'm using postgresql (not sure if it makes a difference)
  • my model ts looks like:
import {Entity, model, property} from '@loopback/repository';

@model()
export class Customer extends Entity {
  @property({
    type: 'string',
    id: true,
    generated: true,
  })
  custid: string;

  @property({
    type: 'string',
    required: true,
  })
  custname: string;

  constructor(data?: Partial<Customer>) {
    super(data);
  }
}

Running \d customer on postgresql, it shows:

testdb=# \d customer
                               Table "public.customer"
  Column  |  Type   | Collation | Nullable |                 Default                  
----------+---------+-----------+----------+------------------------------------------
 custid   | integer |           | not null | nextval('customer_custid_seq'::regclass)
 custname | text    |           | not null | 
Indexes:
    "customer_pkey" PRIMARY KEY, btree (custid)

Current Behavior

custid is of type integer on the database

Expected Behavior

custid should be of type text instead.

See Reporting Issues for more tips on writing good issues

Metadata

Metadata

Assignees

Labels

developer-experienceIssues affecting ease of use and overall experience of LB usersfeature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions