Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set MIN_SCHEMA_VERSION to 12 #2674

Merged
merged 3 commits into from
Aug 29, 2020
Merged

Conversation

hidenori-shinohara
Copy link
Contributor

@hidenori-shinohara hidenori-shinohara commented Aug 17, 2020

Description

Resolves #2601

This change will bump MIN_SCHEMA_VERSION to 12.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v5.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

@MonsieurNicolas
Copy link
Contributor

@hidenori-shinohara this doesn't resolve the issue: the issue tracks collapsing the "create + any schema upgrade pre 12" into just a "create" step (so we create the database at schema 12).

See #2225 for how we did it in the past. We'd have one commit per extra "upgrade" step, so we'd have "squash database schema 10" ... "squash database schema 12".

@hidenori-shinohara
Copy link
Contributor Author

@MonsieurNicolas Thank you for the reference! That really helped me.

I updated the PR. I hope I did it correctly this time.

@MonsieurNicolas MonsieurNicolas added this to In progress in v14.1.0 via automation Aug 21, 2020
@MonsieurNicolas
Copy link
Contributor

I think you did the right thing.

One way to verify is to create a couple databases (sqlite3 and postgresql) using new-db, and compare the output of the special commands that dump the full schema: .schema (sqlite3) and pg_dump -s (postgresql).

Do this against master and against your branch, the output should be the same.

@hidenori-shinohara
Copy link
Contributor Author

I got the outputs against master and my branch and diff'd and their outputs are the same.

Both master and my branch outputted the following for postgres.

--
-- PostgreSQL database dump
--

-- Dumped from database version 12.3
-- Dumped by pg_dump version 12.3

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- PostgreSQL database dump complete
--

and both master and my branch outputted the following for sqlite3:

CREATE TABLE upgradehistory (ledgerseq    INT NOT NULL CHECK (ledgerseq >= 0), upgradeindex INT NOT NULL, upgrade      TEXT NOT NULL, changes      TEXT NOT NULL, PRIMARY KEY (ledgerseq, upgradeindex));
CREATE INDEX upgradehistbyseq ON upgradehistory (ledgerseq);
CREATE TABLE accounts(accountid          VARCHAR(56)   PRIMARY KEY,balance            BIGINT       NOT NULL CHECK (balance >= 0),buyingliabilities  BIGINT CHECK (buyingliabilities >= 0),sellingliabilities BIGINT CHECK (sellingliabilities >= 0),seqnum             BIGINT       NOT NULL,numsubentries      INT          NOT NULL CHECK (numsubentries >= 0),inflationdest      VARCHAR(56),homedomain         VARCHAR(44)  NOT NULL,thresholds         TEXT         NOT NULL,flags              INT          NOT NULL,signers            TEXT,lastmodified       INT          NOT NULL, ledgerext TEXT, extension TEXT);
CREATE TABLE offers(sellerid         VARCHAR(56) NOT NULL,offerid          BIGINT           NOT NULL CHECK (offerid >= 0),sellingasset     TEXT  NOT NULL,buyingasset      TEXT  NOT NULL,amount           BIGINT           NOT NULL CHECK (amount >= 0),pricen           INT              NOT NULL,priced           INT              NOT NULL,price            DOUBLE PRECISION NOT NULL,flags            INT              NOT NULL,lastmodified     INT              NOT NULL, ledgerext TEXT, extension TEXT,PRIMARY KEY      (offerid));
CREATE INDEX bestofferindex ON offers (sellingasset,buyingasset,price,offerid);
CREATE TABLE trustlines(accountid    VARCHAR(56)  NOT NULL,assettype    INT             NOT NULL,issuer       VARCHAR(56)  NOT NULL,assetcode    VARCHAR(12)  NOT NULL,tlimit       BIGINT          NOT NULL CHECK (tlimit > 0),balance      BIGINT          NOT NULL CHECK (balance >= 0),buyingliabilities BIGINT CHECK (buyingliabilities >= 0),sellingliabilities BIGINT CHECK (sellingliabilities >= 0),flags        INT             NOT NULL,lastmodified INT             NOT NULL, ledgerext TEXT, extension TEXT,PRIMARY KEY  (accountid, issuer, assetcode));
CREATE TABLE accountdata(accountid    VARCHAR(56)  NOT NULL,dataname     VARCHAR(88)  NOT NULL,datavalue    VARCHAR(112) NOT NULL,lastmodified INT          NOT NULL, ledgerext TEXT, extension TEXT,PRIMARY KEY  (accountid, dataname));
CREATE TABLE peers (ip            VARCHAR(15) NOT NULL,port          INT DEFAULT 0 CHECK (port > 0 AND port <= 65535) NOT NULL,nextattempt   TIMESTAMP NOT NULL,numfailures   INT DEFAULT 0 CHECK (numfailures >= 0) NOT NULL,type          INT NOT NULL,PRIMARY KEY (ip, port));
CREATE TABLE storestate (statename   CHARACTER(32) PRIMARY KEY,state       TEXT);
CREATE TABLE pubsub (resid       CHARACTER(32) PRIMARY KEY,lastread    INTEGER);
CREATE TABLE ledgerheaders (ledgerhash      CHARACTER(64)  PRIMARY KEY,prevhash        CHARACTER(64) NOT NULL,bucketlisthash  CHARACTER(64) NOT NULL,ledgerseq       INT UNIQUE CHECK (ledgerseq >= 0),closetime       BIGINT NOT NULL CHECK (closetime >= 0),data            TEXT NOT NULL);
CREATE INDEX ledgersbyseq ON ledgerheaders ( ledgerseq );
CREATE TABLE txhistory (txid        CHARACTER(64) NOT NULL,ledgerseq   INT NOT NULL CHECK (ledgerseq >= 0),txindex     INT NOT NULL,txbody      TEXT NOT NULL,txresult    TEXT NOT NULL,txmeta      TEXT NOT NULL,PRIMARY KEY (ledgerseq, txindex));
CREATE INDEX histbyseq ON txhistory (ledgerseq);
CREATE TABLE txfeehistory (txid        CHARACTER(64) NOT NULL,ledgerseq   INT NOT NULL CHECK (ledgerseq >= 0),txindex     INT NOT NULL,txchanges   TEXT NOT NULL,PRIMARY KEY (ledgerseq, txindex));
CREATE INDEX histfeebyseq ON txfeehistory (ledgerseq);
CREATE TABLE publishqueue (ledger   INTEGER PRIMARY KEY,state    TEXT);
CREATE TABLE scphistory (nodeid      CHARACTER(56) NOT NULL,ledgerseq   INT NOT NULL CHECK (ledgerseq >= 0),envelope    TEXT NOT NULL);
CREATE INDEX scpenvsbyseq ON scphistory(ledgerseq);
CREATE TABLE scpquorums (qsethash      CHARACTER(64) NOT NULL,lastledgerseq INT NOT NULL CHECK (lastledgerseq >= 0),qset          TEXT NOT NULL,PRIMARY KEY (qsethash));
CREATE INDEX scpquorumsbyseq ON scpquorums(lastledgerseq);
CREATE TABLE ban (nodeid      CHARACTER(56) NOT NULL PRIMARY KEY);
CREATE TABLE quoruminfo (nodeid      CHARACTER(56) NOT NULL,qsethash    CHARACTER(64) NOT NULL,PRIMARY KEY (nodeid));
CREATE TABLE claimablebalance (balanceid             VARCHAR(48)  PRIMARY KEY, ledgerentry TEXT NOT NULL, lastmodified          INT NOT NULL);

@MonsieurNicolas
Copy link
Contributor

r+ 2817068

@latobarita latobarita merged commit 456d660 into stellar:master Aug 29, 2020
v14.1.0 automation moved this from In progress to Done Aug 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v14.1.0
  
Done
Development

Successfully merging this pull request may close these issues.

Collapse all schemas older than 12 into just 12
3 participants