-- Reference schema for MS SQL Server.
-- Not required to run manually if spring.jpa.hibernate.ddl-auto=update is left enabled,
-- but useful for real deployments where DDL is managed separately.

IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'pdf_file_db')
BEGIN
    CREATE DATABASE pdf_file_db;
END
GO

USE pdf_file_db;
GO

IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'file_document')
BEGIN
    CREATE TABLE file_document (
        id                BIGINT IDENTITY(1,1) PRIMARY KEY,
        original_file_name NVARCHAR(255)  NOT NULL,
        stored_file_name   NVARCHAR(255)  NOT NULL,
        file_path          NVARCHAR(1000) NOT NULL,
        content_type       NVARCHAR(100)  NULL,
        file_size          BIGINT         NOT NULL DEFAULT 0,
        upload_date        DATETIME2      NOT NULL DEFAULT SYSUTCDATETIME()
    );
END
GO
