import sys

class OrganizationsRecord:
    def __init__(self, organization_id, name):
        self.organization_id = organization_id
        self.name = name

f = open(sys.argv[1], mode="r")

dump_file = open(sys.argv[2], mode="w")

rows = f.read().split("\n")

dump_file.write("""
CREATE TABLE evi.organization
(
    organization_id text COLLATE pg_catalog."default" NOT NULL,
    name text COLLATE pg_catalog."default" NOT NULL,
    CONSTRAINT organization_pkey PRIMARY KEY (organization_id),
    CONSTRAINT organization_unique_name_cnt UNIQUE (name)
);
\n""")

for row in rows:
    if len(row) == 0:
        continue

    cols = row.split(",")
    record = OrganizationsRecord(cols[0], cols[1])

    dump_file.write(f"""INSERT INTO evi.organization (organization_id, name)
                    VALUES ('{record.organization_id}', '{record.name}');\n""")
