12245759ac
CI / test (push) Has been cancelled
Web app: new entities (Image, RenderedAsset, SharedImage, Token, DeviceImageHistory), enums, repositories, controllers, message handlers, migrations, tests, frontend upload/library/sticker UI, Vue components. Firmware: EPD background screen binaries + gen scripts, setup_bg header. Infra: ddev config, test bundle, gitignore coverage dir. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.8 KiB
PHP
43 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260507200000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Add shared_image table for family sharing';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql("CREATE TABLE shared_image (
|
|
id SERIAL NOT NULL,
|
|
source_image_id INT NOT NULL,
|
|
recipient_user_id INT NOT NULL,
|
|
shared_by_id INT NOT NULL,
|
|
shared_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,
|
|
status VARCHAR(20) NOT NULL DEFAULT 'pending',
|
|
PRIMARY KEY(id)
|
|
)");
|
|
$this->addSql("COMMENT ON COLUMN shared_image.shared_at IS '(DC2Type:datetime_immutable)'");
|
|
$this->addSql('CREATE INDEX idx_shared_recipient_status ON shared_image (recipient_user_id, status)');
|
|
$this->addSql('ALTER TABLE shared_image ADD CONSTRAINT fk_shared_source FOREIGN KEY (source_image_id) REFERENCES image (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
$this->addSql('ALTER TABLE shared_image ADD CONSTRAINT fk_shared_recipient FOREIGN KEY (recipient_user_id) REFERENCES "user" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
$this->addSql('ALTER TABLE shared_image ADD CONSTRAINT fk_shared_by FOREIGN KEY (shared_by_id) REFERENCES "user" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE shared_image DROP CONSTRAINT fk_shared_source');
|
|
$this->addSql('ALTER TABLE shared_image DROP CONSTRAINT fk_shared_recipient');
|
|
$this->addSql('ALTER TABLE shared_image DROP CONSTRAINT fk_shared_by');
|
|
$this->addSql('DROP TABLE shared_image');
|
|
}
|
|
}
|