CREATE TABLE password_reset (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		username VARCHAR(35) NOT NULL ,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY password_reset
    ADD CONSTRAINT password_reset_id_key UNIQUE (id);


CREATE TABLE members_pending (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		firstname VARCHAR(35)  NOT NULL,
		lastname VARCHAR(35)  NOT NULL,
		email VARCHAR(35) NOT NULL ,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_pending
    ADD CONSTRAINT members_pending_id_key UNIQUE (id);



CREATE TABLE members (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		username VARCHAR(25) UNIQUE NOT NULL,
		password VARCHAR(250)  NOT NULL,
		loc INET,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members
    ADD CONSTRAINT members_id_key UNIQUE (id);

ALTER TABLE members ADD email VARCHAR(100);
ALTER TABLE members ADD account_name VARCHAR(100);
ALTER TABLE members ADD firstname VARCHAR(25);
ALTER TABLE members ADD lastname VARCHAR(25);
ALTER TABLE members ALTER COLUMN password TYPE VARCHAR(250);
ALTER TABLE members ADD country VARCHAR(3);
ALTER TABLE members ADD stripe_customer_id VARCHAR(100)
ALTER TABLE members ADD profile_completed timestamp without time zone DEFAULT NULL;
ALTER TABLE members ADD option_name  VARCHAR(100) REFERENCES subscription_options(option_name);
ALTER TABLE members ADD next_billing timestamp without time zone;
ALTER TABLE members ADD trial_end timestamp without time zone;
-- bALTER TABLE members ADD option_name VARCHAR(100) REFERENCES subscription_options(option_name);

CREATE TABLE members_profile(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	member_id INT REFERENCES members(id) UNIQUE  NOT NULL,
	practice VARCHAR(100)  NOT NULL,
    specialization VARCHAR(100)  NOT NULL,
    introduction TEXT,
	added timestamp without time zone DEFAULT now(),
	updated timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY members_profile
    ADD CONSTRAINT members_members_profile_id_key UNIQUE (id);

ALTER TABLE members_profile OWNER TO merms_panel

ALTER TABLE members_profile ADD url_name VARCHAR(25);



-- UPDATE members SET account_name ='This is the account name';
-- UPDATE members SET firstname ='Firstname';
-- UPDATE members SET lastname ='Lastname';


CREATE TABLE members_session(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	member_id INT REFERENCES members(id),
	session_id VARCHAR(100) UNIQUE NOT NULL,
	loc INET,
	status INT DEFAULT 0,
	added timestamp without time zone DEFAULT now(),
	updated timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY members_session
    ADD CONSTRAINT members_session_id_key UNIQUE (id);



CREATE TABLE products (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		product_id VARCHAR(25) UNIQUE NOT NULL,
		name VARCHAR(100) UNIQUE NOT NULL,
		description VARCHAR(250)  NOT NULL,
		status INT DEFAULT 0,

		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY products
    ADD CONSTRAINT products_id_key UNIQUE (id);

 ALTER TABLE products ADD banner VARCHAR(100);
 UPDATE products set banner  =  'p'||id||'.jpg'

 ALTER TABLE products ADD start_url VARCHAR(100);

--- DEVELOPMENT
  UPDATE products SET start_url = 'A1.devprov.mermsemr.com' WHERE product_id = 'A000001';
  UPDATE products SET start_url = 'A2.devprov.mermsemr.com' WHERE product_id = 'A000002';
  UPDATE products SET start_url = 'A3.devprov.mermsemr.com' WHERE product_id = 'A000003';
  UPDATE products SET start_url = 'A4.devprov.mermsemr.com' WHERE product_id = 'A000004';
  UPDATE products SET start_url = 'A5.devprov.mermsemr.com' WHERE product_id = 'A000005';

--- PRODUCTION
  UPDATE products SET start_url = '.pers.mermsemr.com' WHERE product_id = 'A000001';
  UPDATE products SET start_url = '.prov.mermsemr.com' WHERE product_id = 'A000002';
  UPDATE products SET start_url = 'p.forum.mermsemr.com' WHERE product_id = 'A000003';
  UPDATE products SET start_url = 'v.forum.mermsemr.com' WHERE product_id = 'A000004';
  UPDATE products SET start_url = '.ehr.mermsemr.com' WHERE product_id = 'A000005';


 CREATE TABLE products_details (
		id SERIAL,
		product_id VARCHAR(25) UNIQUE REFERENCES products(product_id),
		details TEXT,
        sale_text TEXT,
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY products_details
    ADD CONSTRAINT products_details_id_key UNIQUE (id);

CREATE TABLE member_product_refresh(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	member_id INT REFERENCES members(id),
	product_id VARCHAR(25)  NOT NULL,
	subscription_uid VARCHAR(100)  NOT NULL,
	status INT DEFAULT 0,
	added timestamp without time zone DEFAULT now(),
	updated timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY member_product_refresh
    ADD CONSTRAINT member_product_refresh_id_key UNIQUE (id);




ALTER TABLE products_details OWNER TO merms_panel;

--- ALTER TABLE products_details ADD sale_text TEXT;

INSERT INTO products_details  (product_id,details) VALUES(
'A000002',
'
A Professional Website service utilizing AI tools offers a comprehensive solution for individuals and businesses looking to establish a robust online presence. Here are some key features typically included in such a service:

1. **AI-Powered Design**: The service often employs AI algorithms to help create aesthetically pleasing and user-friendly designs. Users can enter their preferences and the tools will generate layout suggestions, color schemes, and typography that best match their brand identity.

2. **Content Generation**: With AI-driven content creation tools, users can receive assistance in writing engaging website copy, blog posts, and product descriptions. These tools can analyze successful content in similar industries and generate text that aligns with SEO best practices.

3. **SEO Optimization**: AI tools can help optimize websites for search engines by analyzing keywords, providing suggestions for improving visibility, and optimizing site architecture. This ensures that the website ranks well and attracts organic traffic.

4. **Chatbots for Customer Engagement**: Implementing AI chatbots allows businesses to provide instant support to visitors. These bots can answer common questions, guide users through the website, and enhance the overall customer experience.

5. **Analytics and Insights**: Advanced AI analytics can track user behavior, providing insights into how visitors interact with the site. This data helps businesses make informed decisions on improvements and marketing strategies.

6. **Personalization**: Using AI, websites can personalize user experiences based on behavior and preferences. This could include tailored recommendations, customized content, and targeted marketing campaigns that increase engagement.

7. **E-commerce Solutions**: For those looking to sell online, AI tools can optimize the shopping experience by providing product recommendations, personalized discounts, and streamlined check-out processes.

8. **Maintenance and Support**: Many services offer ongoing support and automatic updates using AI to monitor site performance, ensuring that the website runs smoothly and is protected against threats. By leveraging these AI tools, the Professional Website service can deliver not only visually appealing and functional websites but also enhance user engagement, improve operational efficiency, and drive growth for businesses.
'
);details

INSERT INTO products_details  (product_id,details) VALUES ('A000002','
<p>Elevate your online presence with a professional website service powered by cutting-edge AI tools. This all-inclusive solution empowers individuals and businesses to create a dynamic and impactful digital footprint. Key features of this service include powerful content generation, strategic SEO optimization, insightful analytics, personalized experiences, and much more.
</p><p>
Experience the transformative potential of a robust online platform that drives engagement and success!</p>'
);

INSERT INTO products_details  (product_id,details) VALUES ('A000001', '
<p>Establishing a powerful online presence is crucial in todays digital landscape. Our platform empowers you to effortlessly organize and manage every aspect of your website.
</p><p>
With our cutting-edge features, you will benefit from advanced SEO optimization that drives traffic, comprehensive analytics that provide valuable insights, and tailored experiences that engage your audience like never before.
</p><p>
Transform your online presence with us and unlock your full potential!</p>');

INSERT INTO products_details  (product_id,details) VALUES ('A000003', '
<p>Unlock your potential with your personalized sharing forum. We handle the platform management, allowing you to focus on impactful outreach and communication. Utilize our powerful tools to significantly expand your audience and amplify your message.
</p><p>
We are here to support you every step of the way in achieving your goals.</p>');


INSERT INTO products_details  (product_id,details) VALUES ('A000004', '
<p>Elevate your business online presence by launching an engaging forum where you can exchange ideas and information with your users. This forum will not only foster meaningful interactions but also serve as a vital point of connection for your clients.
</p><p>
We partner with you to implement automated engagements, streamline appointments, create valuable links, and much more, ensuring a seamless experience that drives your success.</p>');

INSERT INTO products_details  (product_id,details) VALUES ('A000005', '
<p><b>OpenEMR</b> is the most popular open source electronic health records and medical practice management solution. OpenEMR is a community of passionate volunteers and contributors dedicated to guarding OpenEMR status as a free, open source software solution for medical practices with a commitment to openness, kindness and cooperation.
</p><p>
Activate to deploy OpenEMR for your practice
</p><p>
URL: https://www.open-emr.org/ </p>');





UPDATE products_details  SET details =   '
<p>Elevate your online presence with a professional website service powered by cutting-edge AI tools. This all-inclusive solution empowers individuals and businesses to create a dynamic and impactful digital footprint. ' ||
                                         '
Experience the transformative potential of a robust online platform that drives engagement and success!</p>'
WHERE product_id = 'A000002';




INSERT INTO products_details  (product_id,details) VALUES(
'A000001',
'
A Professional Website service utilizing AI tools offers a comprehensive solution for individuals and businesses looking to establish a robust online presence. Here are some key features typically included in such a service'
);


UPDATE products_details SET sale_text =
'<br>
<hr>
Start free for 6 months, and customize your product with additional features as you see fit. You''re in control-you can cancel anytime.
<hr>
<br>';

merms_panel=# select product_id,description from products;
 product_id |                 description
------------+----------------------------------------------
 A000002    | Your healthcare practice online presence
 A000001    | Your personal professional web presence
 A000003    | Blog to share your health care view
 A000004    | Booster your practice with engaging contents
 A000005    | Get Open EMR for practice management
(5 rows)

 CREATE TABLE products_templates (
		id SERIAL,
     	uid uuid DEFAULT  uuid_generate_v4(),
		product_id VARCHAR(25)  REFERENCES products(product_id),
		name VARCHAR(55) UNIQUE NOT NULL,
        status INT DEFAULT 0,
        owner_uid VARCHAR(100),
        provision_name VARCHAR(250),
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY products_templates
    ADD CONSTRAINT products_templates_id_key UNIQUE (id);

ALTER TABLE products_templates OWNER TO merms_panel;


INSERT INTO products_templates(product_id,name,provision_name,status)
VALUES(
      'A000001',
      'Template A01',
      'registry.chiefsoft.com/pweb/pweb-01-merms-pweb0004:latest',
      1);

INSERT INTO products_templates(product_id,name,provision_name,status)
VALUES(
      'A000001',
      'Template A02',
      'registry.chiefsoft.com/pweb/pweb-01-merms-pweb0005:latest',
       1);

INSERT INTO products_templates(product_id,name,provision_name,status)
VALUES(
      'A000001',
      'Template A03',
      'registry.chiefsoft.com/pweb/pweb-01-merms-pweb0006:latest',
       1);


INSERT INTO products_templates(product_id,name,provision_name,status)
VALUES(
      'A000002',
      'Practice B01',
      'registry.chiefsoft.com/pweb/pweb-01-merms-pweb0007:latest',
       1
     );

INSERT INTO products_templates(product_id,name,provision_name,status)
VALUES(
      'A000002',
      'Practice B02',
      'registry.chiefsoft.com/pweb/pweb-01-merms-pweb0008:latest',
       1
     );

INSERT INTO products_templates(product_id,name,provision_name,status)
VALUES(
      'A000002',
      '',
      ''
     );


CREATE TABLE members_products (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
		product_id VARCHAR(25) REFERENCES products(product_id),
		internal_url VARCHAR(100) UNIQUE NOT NULL,
		external_url VARCHAR(100),
		dns_group VARCHAR(20),
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_products
    ADD CONSTRAINT members_products_id_key UNIQUE (id);

ALTER TABLE members_products
ADD CONSTRAINT members_products_unique_member_key
UNIQUE (member_id, product_id);

ALTER TABLE  members_products ADD provision_port INT DEFAULT 0;
ALTER TABLE  members_products ADD primary_server VARCHAR(100);
ALTER TABLE  members_products ADD db_status INT DEFAULT 0;
ALTER TABLE  members_products ADD provision_status INT DEFAULT 0;
ALTER TABLE  members_products ADD p_file INT DEFAULT 0;
ALTER TABLE  members_products ADD url_status INT DEFAULT 0;
ALTER TABLE  members_products ADD product_template  VARCHAR(100);
ALTER TABLE  members_products ADD custom_template  VARCHAR(100);

-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Personal Website','Your personal professional web presence',1,'A000001', 'banner.jpg');
-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Professional Website','Your healthcare practice online presence ',1,'A000002', 'banner.jpg');
-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Personal Blog','Blog to share your health care view',1,'A000003', 'banner.jpg');
-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Professional Blog','Booster your practice with engaging contents',1,'A000004', 'banner.jpg');
-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Practice EMR','Get Open EMR for practice management',1,'A000005', 'banner.jpg');

INSERT INTO products (name,description,status,product_id, banner) VALUES ('Personal Website','Your personal professional web presence',1,'A000001', 'banner.jpg');
INSERT INTO products (name,description,status,product_id, banner) VALUES ('Professional Website','Your healthcare practice online presence ',1,'A000002', 'banner.jpg');
INSERT INTO products (name,description,status,product_id, banner) VALUES ('Personal Blog','Blog to share your health care view',1,'A000003', 'banner.jpg');
INSERT INTO products (name,description,status,product_id, banner) VALUES ('Professional Blog','Booster your practice with engaging contents',1,'A000004', 'banner.jpg');
INSERT INTO products (name,description,status,product_id, banner) VALUES ('Practice EMR','Get Open EMR for practice management',1,'A000005', 'banner.jpg');


CREATE TABLE members_products_settings (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
        subscription_uid VARCHAR(150),
		product_id VARCHAR(25) REFERENCES products(product_id),
		settings_key VARCHAR(100) NOT NULL,
		setting_type VARCHAR(15) NOT NULL,
		setting_value TEXT,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_products_settings
    ADD CONSTRAINT members_products_settings_id_key UNIQUE (id);

ALTER TABLE members_products_settings
ADD CONSTRAINT members_products_settings_unique_member_key
UNIQUE (member_id, product_id, settings_key);

ALTER TABLE members_products_settings OWNER TO merms_panel;
-- member_id,subscription_uid,product_id,settings_key,setting_type,setting_value


CREATE TABLE provision_plans (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		provision_id INT REFERENCES members_products(id),
		play_file  VARCHAR(100)UNIQUE  NOT NULL,
		msg VARCHAR(100) ,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY provision_plans
    ADD CONSTRAINT provision_plans_id_key UNIQUE (id);



CREATE TABLE members_external_links (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
		member_uid  VARCHAR(100)  NOT NULL,
		facebook VARCHAR(125),
		google VARCHAR(125),
		linkedin VARCHAR(125),
		other_web VARCHAR(125),
		twitter VARCHAR(125),
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_external_links
    ADD CONSTRAINT members_external_links_id_key UNIQUE (id);


CREATE TABLE provision_actions (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
		product_uid  VARCHAR(100)  NOT NULL,
		action VARCHAR(100)  NOT NULL,
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY provision_actions
    ADD CONSTRAINT provision_actions_id_key UNIQUE (id);

	         {"id": "3", "action": "Verifying your product..." , "date": "10-10-2010 11:00 AM"},
         {"id": "2", "action": "URL assigned - Progress on the URL " , "date": "10-10-2010 11:30 AM"},
         {"id": "1", "action": "Initiating product creation" , "date": "10-12-2010 11:30 AM"},



CREATE TABLE members_actions (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
		member_uid  VARCHAR(100)  NOT NULL,
		action_label VARCHAR(35)  NOT NULL,
		action_name  VARCHAR(100)  NOT NULL,
		status_description VARCHAR(25)  NOT NULL,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_actions
    ADD CONSTRAINT members_actions_id_key UNIQUE (id);



CREATE TABLE subscription_options (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		display_name  VARCHAR(25) UNIQUE NOT NULL,
    	option_name  VARCHAR(100) UNIQUE NOT NULL,
		monthly INT DEFAULT 0,
		status INT DEFAULT 1,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY subscription_options
    ADD CONSTRAINT subscription_options_id_key UNIQUE (id);

ALTER TABLE  subscription_options ADD stripe_product_id VARCHAR(100);
ALTER TABLE  subscription_options ADD stripe_price_id VARCHAR(100);

ALTER TABLE subscription_options OWNER TO merms_panel;


INSERT INTO subscription_options(display_name,option_name,monthly)
VALUES ('Starter','STATRTER001',599);

INSERT INTO subscription_options(display_name,option_name,monthly)
VALUES ('Basic','BASIC001',1299);

INSERT INTO subscription_options(display_name,option_name,monthly)
VALUES ('Premium','PREMIUM001',2099);


CREATE TABLE subscription_options_items (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
    	option_name  VARCHAR(100) REFERENCES subscription_options(option_name),
		description  VARCHAR(100)  NOT NULL,
    	list_order INT DEFAULT 0,
		status INT DEFAULT 1,
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY subscription_options_items
    ADD CONSTRAINT subscription_options_items_id_key UNIQUE (id);


CREATE TABLE  payments_session(
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
        member_id INT REFERENCES members(id),
        option_name VARCHAR(100) REFERENCES subscription_options(option_name),
        processor VARCHAR(25) NOT NULL,
        session_id VARCHAR(150) NOT NULL,
        status INT DEFAULT 1,
		added timestamp without time zone DEFAULT now(),
        updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY payments_session
    ADD CONSTRAINT payments_session_id_key UNIQUE (id);

ALTER TABLE payments_session OWNER TO merms_panel;

--
--     __tablename__ = 'payments_session'
--
--     id = db.Column(
--         db.Integer,
--         primary_key=True,
--         autoincrement=True,
--     )
--     uid = db.Column(db.String(150), nullable=True)
--     member_id = db.Column(db.Integer, nullable=False)
--     product_id = db.Column(db.String(25), nullable=False)
--     processor = db.Column(db.String(25), nullable=False)
--     session_id = db.Column(db.String(150), nullable=False)
--     status = db.Column(db.Integer, nullable=True, default=1)
--     added = db.Column(db.DateTime(timezone=True), server_default=func.now())
--     updated = db.Column(db.DateTime(timezone=True), server_default=func.now(), onupdate=func.now())




CREATE TABLE payments (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
        member_id INT REFERENCES members(id),
    	option_name  VARCHAR(100) REFERENCES subscription_options(option_name),
        option_type VARCHAR(25),
        payment_uid VARCHAR(100) UNIQUE  NOT NULL,
        amount INT DEFAULT 0,
		status INT DEFAULT 1,
		added timestamp without time zone DEFAULT now(),
        sub_start timestamp without time zone,
        next_billing timestamp without time zone,
        sub_stop timestamp without time zone
	);
 ALTER TABLE ONLY payments
    ADD CONSTRAINT payments_id_key UNIQUE (id);

ALTER TABLE payments OWNER TO merms_panel;

 {'payment_uid': UUID('360b8829-45e0-4419-bcf0-18f4087f14b9'), 'member_id': 1, 'option_name': 'STATRTER001'}



ALTER TABLE subscription_options_items OWNER TO merms_panel;

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('STATRTER001','Personal Web Presence',0);
INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('STATRTER001','Professional Online Presence',2);
INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('STATRTER001','Personal and Professional Forum',4);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('STATRTER001','Contacts Management',6);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('STATRTER001','Site Monitoring ',8);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('STATRTER001','',0);




INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('BASIC001','Everything in Starter Plus',0);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('BASIC001','5 Site Plugins',2);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('BASIC001','1 Automatic Content Posting per Week',4);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('BASIC001','Basic Site Traffic Engagement',6);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('BASIC001','Basic Site Intelligence',8);



INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('BASIC001','',0);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('BASIC001','',0);




INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('PREMIUM001','Everything in Starter & Basic Plus',0);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('PREMIUM001','',0);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('PREMIUM001','',0);

INSERT INTO subscription_options_items (option_name,description,list_order)
    VALUES('PREMIUM001','',0);


DROP TABLE subscription_generative;

CREATE TABLE subscription_generative(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	member_id INT REFERENCES members(id),
	practice VARCHAR(100)  NOT NULL,
	specialization VARCHAR(100)  NOT NULL,
    product_id VARCHAR(25)  NOT NULL,
    subscription_uid VARCHAR(100)  NOT NULL,
    status INT DEFAULT 0,
	added timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY subscription_generative
    ADD CONSTRAINT subscription_generative_id_key UNIQUE (id);

ALTER TABLE subscription_generative OWNER TO merms_panel;

CREATE TABLE generative_results(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	member_id INT REFERENCES members(id)   NOT NULL,
	product_id VARCHAR(25)  NOT NULL,
	var_name VARCHAR(100)  NOT NULL,
	subscription_uid VARCHAR(100)  NOT NULL,
    text_result TEXT,
    status INT DEFAULT 0,
	added timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY generative_results
    ADD CONSTRAINT generative_results_id_key UNIQUE (id);

ALTER TABLE generative_results OWNER TO merms_panel;


CREATE TABLE office_users(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	username VARCHAR(25) UNIQUE NOT NULL,
	password VARCHAR(100)  NOT NULL,
    firstname VARCHAR(25)  NOT NULL,
    lastname VARCHAR(25)  NOT NULL,
    acc_level INT DEFAULT 10,
    status INT DEFAULT 0,
	added timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY office_users
    ADD CONSTRAINT office_users_id_key UNIQUE (id);

ALTER TABLE office_users OWNER TO merms_panel;

INSERT  INTO office_users (username, password, firstname, lastname, acc_level) VALUES ('mermsadmin','password','Merms','Admin',1000);



CREATE TABLE products_contacts(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	username VARCHAR(25) UNIQUE NOT NULL,
	product_id VARCHAR(25)  NOT NULL,
	subscription_uid VARCHAR(100)  NOT NULL,
	title VARCHAR(100)  NOT NULL,
    sender VARCHAR(120)  NOT NULL,
    message TEXT,
    status INT DEFAULT 0,
	added timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY products_contacts
    ADD CONSTRAINT products_contacts_id_key UNIQUE (id);

ALTER TABLE products_contacts OWNER TO merms_panel;


 CREATE TABLE custom_templates (
		id SERIAL,
     	uid uuid DEFAULT  uuid_generate_v4(),
		custom_id VARCHAR(25)  UNIQUE NOT NULL,
        provision_name VARCHAR(250),
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY custom_templates
    ADD CONSTRAINT custom_templates_id_key UNIQUE (id);

ALTER TABLE custom_templates OWNER TO merms_panel;

INSERT INTO custom_templates(custom_id,provision_name)  VALUES('icare_template','registry.chiefsoft.com/custom/mermsicare-mermshostedicare-001:latest');

INSERT INTO custom_templates(custom_id,provision_name)  VALUES('kevkem_template','registry.chiefsoft.com/custom/mermskevkem-mermshostedicare-001:latest');

icare_template
registry.chiefsoft.com/custom/mermsicare-mermshostedicare-001:latest


kevkem_template
registry.chiefsoft.com/custom/mermskevkem-mermshostedicare-001:latest



            new_l = {
                        "uid": "425611f2-c692-4404-b93d-76ca7a5ce7" + str(x),
                        "title": "Contact Random Item on " + str(x),
                        "category": cat_list[random.randint(0, 3)],
                        "added": calDate,
                        "sender": "Firstname Lastname" + str(random.randint(1, 4)),
                        "message": dummy_message()
                    }





                    "options": {
                       "starter":{
                           "package_uid" : "cd2c0a4d-9ad4-472e-96f5-28d10c06916f",
                           "display_name" : "Starter",
                           "monthly" : 5.99,
                            "items" : ['Post Jobs','advanced instructors search','invite candidates','post events',
                                       'Cancel anythime']
                       },
                        "basic": {
                            "package_uid": "ef2ffa1c-9272-42cd-9d33-0e614047b4f8",
                            "display_name": "Basic",
                            "monthly": 12.99,
                            "items": ['Post Jobs', 'advanced instructors search', 'invite candidates', 'post events',
                                      'Cancel anythime']
                        },
                        "premium": {
                            "package_uid": "64bf48f6-1e7f-402e-8ff0-76f4ce0f2055",
                            "display_name": "Premium",
                            "monthly": 20.99,
                            "items": ['Post Jobs', 'advanced instructors search', 'invite candidates', 'post events',
                                      'Cancel anythime']
                        },

const insertQuery = 'INSERT INTO ss_subs(members_id, members_uid, action_label,action_name,status_description,status ) VALUES($1, $2, $3, $4, $5, %6)'

      var Querydata = {
            "members_id": req.query.uid,
            "members_uid": req.query.member_id,
            "action_label": 'processing',
			"action_name": 'processing',
            "status_description": req.query.page
			"status": 0
        };
await db.query(insertQuery, Querydata, (err, res) => {
  if (err) {
    console.log(err.stack)
  } else {
    console.log(res.rows[0])

  }


{
    "email": "ameye@chiefsoft.com",
    "firstname": "Olusesan",
    "lastname": "Ameye",
    "isChecked": true
}


CREATE TABLE ttt (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		username VARCHAR(35) NOT NULL
	);









-- up

ALTER TABLE myoldtable ADD COLUMN newcolumn TEXT;
ALTER TABLE myoldtable ADD CONSTRAINT myoldtable_oldcolumn_newcolumn_key UNIQUE (oldcolumn, newcolumn);

---

ALTER TABLE myoldtable DROP CONSTRAINT myoldtable_oldcolumn_newcolumn_key;
ALTER TABLE myoldtable DROP COLUMN newcolumn;

-- down

merms_panel=# \d products
                                         Table "public.products"
   Column    |            Type             | Collation | Nullable |               Default
-------------+-----------------------------+-----------+----------+--------------------------------------
 id          | integer                     |           | not null | nextval('products_id_seq'::regclass)
 uid         | uuid                        |           |          | uuid_generate_v4()
 product_id  | character varying(25)       |           | not null |
 name        | character varying(100)      |           | not null |
 description | character varying(250)      |           | not null |
 status      | integer                     |           |          | 0
 added       | timestamp without time zone |           |          | now()
 updated     | timestamp without time zone |           |          | now()
 banner      | character varying(100)      |           |          |
Indexes:
    "products_id_key" UNIQUE CONSTRAINT, btree (id)
    "products_name_key" UNIQUE CONSTRAINT, btree (name)
    "products_product_id_key" UNIQUE CONSTRAINT, btree (product_id)



CREATE TABLE products_actions (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		product_id VARCHAR(25) UNIQUE NOT NULL,
		name VARCHAR(100) UNIQUE NOT NULL,
		description VARCHAR(250)  NOT NULL,
		status INT DEFAULT 0,

		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY products_actions
    ADD CONSTRAINT products_actions_id_key UNIQUE (id);



 "name" => "Professional Website",
                "description" => "Your healthcare practice online presence ",
                "status" => 0,
                "product" => 'A000002'





INSERT INTO members (username,email,password)
VALUES
('testaccount','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('sanyaameye','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('lekanaderibigbe','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('kevkemchiro','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('icarementalhealth','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('kintcare','works@chiefsoft.com',md5('merms.user.panel'));




















su - postgres
createuser merms_panel
createdb merms_panel

psql template1 postgres

alter user merms_panel with encrypted password 'merms_panel';
grant all privileges on database merms_panel to merms_panel;



















