Люди, помогите.
Не получается создать базу из SQL запроса
Код ниже.
CREATE TABLE Offices (
id SERIAL NOT NULL,
officeName varchar(200) NOT NULL,
createdAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
updatedAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
userId int NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE Departments (
id SERIAL NOT NULL,
departmentName varchar(200) NOT NULL,
officeId int NOT NULL,
createdAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
updatedAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
userId int NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE Employees (
id SERIAL NOT NULL,
firstName varchar(150) NOT NULL,
lastName varchar(150) NOT NULL,
departmentId int NOT NULL,
enabled bool NOT NULL,
createdAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
updatedAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
userId int NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE InventoryHelper (
id SERIAL NOT NULL,
inventoryName varchar(250) NOT NULL,
inventoryNumber varchar(50) NOT NULL,
description TEXT NOT NULL,
createdAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
updatedAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
userId int NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE Transfer (
id SERIAL NOT NULL,
inventoryId int NOT NULL,
actNumber int NOT NULL,
dateOfAct TIMESTAMP(0) NOT NULL,
inventoryCount int NOT NULL,
empFrom int NOT NULL,
empTo int NOT NULL,
createdAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
updatedAt TIMESTAMP(0) NOT NULL CURRENT_TIMESTAMP,
userId int NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE Users (
id SERIAL NOT NULL,
login varchar(100) NOT NULL UNIQUE,
password varchar(100) NOT NULL,
PRIMARY KEY (id)
);
ALTER TABLE Offices ADD CONSTRAINT Offices_fk0 FOREIGN KEY (userId) REFERENCES Users(id);
ALTER TABLE Departments ADD CONSTRAINT Departments_fk0 FOREIGN KEY (officeId) REFERENCES Offices(id);
ALTER TABLE Departments ADD CONSTRAINT Departments_fk1 FOREIGN KEY (userId) REFERENCES Users(id);
ALTER TABLE Employees ADD CONSTRAINT Employees_fk0 FOREIGN KEY (departmentId) REFERENCES Departments(id);
ALTER TABLE Employees ADD CONSTRAINT Employees_fk1 FOREIGN KEY (userId) REFERENCES Users(id);
ALTER TABLE InventoryHelper ADD CONSTRAINT InventoryHelper_fk0 FOREIGN KEY (userId) REFERENCES Users(id);
ALTER TABLE Transfer ADD CONSTRAINT Transfer_fk0 FOREIGN KEY (inventoryId) REFERENCES InventoryHelper(id);
ALTER TABLE Transfer ADD CONSTRAINT Transfer_fk1 FOREIGN KEY (empFrom) REFERENCES Employees(id);
ALTER TABLE Transfer ADD CONSTRAINT Transfer_fk2 FOREIGN KEY (empTo) REFERENCES Employees(id);
ALTER TABLE Transfer ADD CONSTRAINT Transfer_fk3 FOREIGN KEY (userId) REFERENCES Users(id);
БД создаётся командой CREATE
БД создаётся командой CREATE DATABASE а у вас её нет
Ошибок, которые вам выдаёт PostgreSQL я тоже не вижу.