package schema

import (
	"time"

	"github.com/uptrace/bun"
)

type MediaFile struct {
	bun.BaseModel `bun:"table:media_file"`

	ID             string    `bun:"id,pk"`
	CreatedAt      time.Time `bun:"created_date,nullzero,notnull,default:current_timestamp"`
	UpdatedAt      time.Time `bun:"last_modified_date,nullzero,notnull,default:current_timestamp"`
	Version        int       `bun:"version,default:0"`
	CloudLink      string    `bun:"cloud_link"`
	FileName       string    `bun:"file_name"`
	Path           string    `bun:"path"`
	Review         bool      `bun:"review"`
	Title          string    `bun:"title"`
	WebLink        string    `bun:"url,unique:url"`
	ShouldDownload bool      `bun:"should_download"`

	MediaActorFiles []MediaActorFile `bun:"rel:has-many,join:id=media_file_id"`
}

type MediaActor struct {
	bun.BaseModel `bun:"table:media_actor"`

	ID        string    `bun:"id,pk"`
	CreatedAt time.Time `bun:"created_date,nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:"last_modified_date,nullzero,notnull,default:current_timestamp"`
	Version   int       `bun:"version,default:0"`
	Name      string    `bun:"name"`
	WebLink   string    `bun:"url,unique:url"`

	MediaActorFiles []MediaActorFile `bun:"rel:has-many,join:id=media_actor_id"`
}

type MediaActorFile struct {
	bun.BaseModel `bun:"table:media_actor_file"`

	ID           string      `bun:"id,pk"`
	CreatedAt    time.Time   `bun:"created_date,nullzero,notnull,default:current_timestamp"`
	UpdatedAt    time.Time   `bun:"last_modified_date,nullzero,notnull,default:current_timestamp"`
	Version      int         `bun:"version,default:0"`
	MediaActorID *string     `bun:"media_actor_id"`
	MediaActor   *MediaActor `bun:"rel:belongs-to,join:media_actor_id=id"`
	MediaFileID  *string     `bun:"media_file_id"`
	MediaFile    *MediaFile  `bun:"rel:belongs-to,join:media_file_id=id"`
}

type MediaArticle struct {
	bun.BaseModel `bun:"table:media_article"`

	ID        string    `bun:"id,pk"`
	CreatedAt time.Time `bun:"created_date,nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:"last_modified_date,nullzero,notnull,default:current_timestamp"`
	Version   int       `bun:"version,default:0"`
	Review    bool      `bun:"review"`
	Title     string    `bun:"title"`
	WebLink   string    `bun:"url,unique:url"`
}

type MediaVideo struct {
	bun.BaseModel `bun:"table:media_article"`

	ID             string    `bun:"id,pk"`
	CreatedAt      time.Time `bun:"created_date,nullzero,notnull,default:current_timestamp"`
	UpdatedAt      time.Time `bun:"last_modified_date,nullzero,notnull,default:current_timestamp"`
	Version        int       `bun:"version,default:0"`
	CloudLink      string    `bun:"cloud_link"`
	FileName       string    `bun:"file_name"`
	Path           string    `bun:"path"`
	Review         bool      `bun:"review"`
	Title          string    `bun:"title"`
	WebLink        string    `bun:"url,unique:url"`
	ShouldDownload bool      `bun:"should_download"`
}
