CREATE TABLE "domain_backlinks" (
	"id" text PRIMARY KEY NOT NULL,
	"site_id" text NOT NULL,
	"source_url" text NOT NULL,
	"source_title" text,
	"source_domain" text NOT NULL,
	"target_url" text NOT NULL,
	"anchor" text,
	"authority" integer,
	"nofollow" boolean DEFAULT false NOT NULL,
	"sponsored" boolean DEFAULT false NOT NULL,
	"ugc" boolean DEFAULT false NOT NULL,
	"sitewide" boolean DEFAULT false NOT NULL,
	"placement" text DEFAULT 'text' NOT NULL,
	"first_seen" timestamp with time zone,
	"last_seen" timestamp with time zone,
	"is_new" boolean DEFAULT false NOT NULL,
	"is_lost" boolean DEFAULT false NOT NULL,
	"imported_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "domain_backlinks" ADD CONSTRAINT "domain_backlinks_site_id_sites_id_fk" FOREIGN KEY ("site_id") REFERENCES "public"."sites"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "domain_backlinks_site_idx" ON "domain_backlinks" USING btree ("site_id");--> statement-breakpoint
CREATE INDEX "domain_backlinks_site_authority_idx" ON "domain_backlinks" USING btree ("site_id","authority");