Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@ CREATE TABLE public.compiled_contracts_sources (
id uuid DEFAULT gen_random_uuid() NOT NULL,
compilation_id uuid NOT NULL,
source_hash bytea NOT NULL,
path character varying NOT NULL
path character varying NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL
);


Expand Down Expand Up @@ -1138,6 +1139,20 @@ ALTER TABLE ONLY public.verified_contracts
CREATE INDEX code_code_hash_keccak ON public.code USING btree (code_hash_keccak);


--
-- Name: code_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX code_created_at ON public.code USING btree (created_at);


--
-- Name: compiled_contracts_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX compiled_contracts_created_at ON public.compiled_contracts USING btree (created_at);


--
-- Name: compiled_contracts_creation_code_hash; Type: INDEX; Schema: public; Owner: -
--
Expand All @@ -1159,6 +1174,13 @@ CREATE INDEX compiled_contracts_runtime_code_hash ON public.compiled_contracts U
CREATE INDEX compiled_contracts_sources_compilation_id ON public.compiled_contracts_sources USING btree (compilation_id);


--
-- Name: compiled_contracts_sources_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX compiled_contracts_sources_created_at ON public.compiled_contracts_sources USING btree (created_at);


--
-- Name: compiled_contracts_sources_source_hash; Type: INDEX; Schema: public; Owner: -
--
Expand All @@ -1180,6 +1202,20 @@ CREATE INDEX contract_deployments_address ON public.contract_deployments USING b
CREATE INDEX contract_deployments_contract_id ON public.contract_deployments USING btree (contract_id);


--
-- Name: contract_deployments_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX contract_deployments_created_at ON public.contract_deployments USING btree (created_at);


--
-- Name: contracts_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX contracts_created_at ON public.contracts USING btree (created_at);


--
-- Name: contracts_creation_code_hash; Type: INDEX; Schema: public; Owner: -
--
Expand All @@ -1201,13 +1237,27 @@ CREATE INDEX contracts_creation_code_hash_runtime_code_hash ON public.contracts
CREATE INDEX contracts_runtime_code_hash ON public.contracts USING btree (runtime_code_hash);


--
-- Name: sources_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX sources_created_at ON public.sources USING btree (created_at);


--
-- Name: verified_contracts_compilation_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX verified_contracts_compilation_id ON public.verified_contracts USING btree (compilation_id);


--
-- Name: verified_contracts_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX verified_contracts_created_at ON public.verified_contracts USING btree (created_at);


--
-- Name: verified_contracts_deployment_id; Type: INDEX; Schema: public; Owner: -
--
Expand All @@ -1229,6 +1279,13 @@ CREATE TRIGGER insert_set_created_at BEFORE INSERT ON public.code FOR EACH ROW E
CREATE TRIGGER insert_set_created_at BEFORE INSERT ON public.compiled_contracts FOR EACH ROW EXECUTE FUNCTION public.trigger_set_created_at();


--
-- Name: compiled_contracts_sources insert_set_created_at; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER insert_set_created_at BEFORE INSERT ON public.compiled_contracts_sources FOR EACH ROW EXECUTE FUNCTION public.trigger_set_created_at();


--
-- Name: contract_deployments insert_set_created_at; Type: TRIGGER; Schema: public; Owner: -
--
Expand Down Expand Up @@ -1397,6 +1454,13 @@ CREATE TRIGGER update_reuse_created_at BEFORE UPDATE ON public.code FOR EACH ROW
CREATE TRIGGER update_reuse_created_at BEFORE UPDATE ON public.compiled_contracts FOR EACH ROW EXECUTE FUNCTION public.trigger_reuse_created_at();


--
-- Name: compiled_contracts_sources update_reuse_created_at; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER update_reuse_created_at BEFORE UPDATE ON public.compiled_contracts_sources FOR EACH ROW EXECUTE FUNCTION public.trigger_reuse_created_at();


--
-- Name: contract_deployments update_reuse_created_at; Type: TRIGGER; Schema: public; Owner: -
--
Expand Down Expand Up @@ -1635,4 +1699,5 @@ ALTER TABLE ONLY public.verified_contracts
INSERT INTO public.schema_migrations (version) VALUES
('20250717103432'),
('20250723145429'),
('20251023134207');
('20251023134207'),
('20251106144315');
38 changes: 38 additions & 0 deletions migrations/20251106144315_add_created_at_indexes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- migrate:up

ALTER TABLE compiled_contracts_sources
ADD COLUMN created_at timestamptz NOT NULL DEFAULT NOW();

CREATE TRIGGER insert_set_created_at
BEFORE INSERT ON compiled_contracts_sources
FOR EACH ROW
EXECUTE FUNCTION trigger_set_created_at();

CREATE TRIGGER update_reuse_created_at
BEFORE UPDATE ON compiled_contracts_sources
FOR EACH ROW
EXECUTE FUNCTION trigger_reuse_created_at();

CREATE INDEX code_created_at ON code USING btree(created_at);
CREATE INDEX compiled_contracts_created_at ON compiled_contracts USING btree(created_at);
CREATE INDEX compiled_contracts_sources_created_at ON compiled_contracts_sources USING btree(created_at);
CREATE INDEX contract_deployments_created_at ON contract_deployments USING btree(created_at);
CREATE INDEX contracts_created_at ON contracts USING btree(created_at);
CREATE INDEX sources_created_at ON sources USING btree(created_at);
CREATE INDEX verified_contracts_created_at ON verified_contracts USING btree(created_at);

-- migrate:down

DROP INDEX IF EXISTS verified_contracts_created_at;
DROP INDEX IF EXISTS sources_created_at;
DROP INDEX IF EXISTS contracts_created_at;
DROP INDEX IF EXISTS contract_deployments_created_at;
DROP INDEX IF EXISTS compiled_contracts_sources_created_at;
DROP INDEX IF EXISTS compiled_contracts_created_at;
DROP INDEX IF EXISTS code_created_at;

DROP TRIGGER IF EXISTS update_reuse_created_at ON compiled_contracts_sources;
DROP TRIGGER IF EXISTS insert_set_created_at ON compiled_contracts_sources;

ALTER TABLE compiled_contracts_sources
DROP COLUMN IF EXISTS created_at;