--- company-details

CREATE TABLE company_details (
  company_id            BIGINT PRIMARY KEY REFERENCES companies (id),

  inn                   NVARCHAR(1024),
  kpp                   NVARCHAR(1024),
  resident              BIT            NOT NULL,
  phone                 NVARCHAR(1024),
  short_name            NVARCHAR(1024),
  international_name    NVARCHAR(1024),
  ogrn                  NVARCHAR(1024),
  ogrn_date             NVARCHAR(1024),
  international_address NVARCHAR(1024),

  created_at            DATETIMEOFFSET NOT NULL,
  updated_at            DATETIMEOFFSET NOT NULL
);

INSERT INTO company_details (company_id, resident, created_at, updated_at) (
  SELECT
    c.id,
    1,
    sysdatetimeoffset(),
    sysdatetimeoffset()
  FROM companies c
);
