sql.append("index SERIAL NOT NULL, ");
sql.append("id TEXT PRIMARY KEY, ");
sql.append("CONSTRAIN id PRIMARY KEY (id)"); <== Error
This is quite confusing, having the index column be serial but not PK (or even unique…) while the id column is the PK, which you’ve redundantly specified.
David J.