chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:32:25 +08:00
commit e014feafe1
2285 changed files with 1131979 additions and 0 deletions
+280
View File
@@ -0,0 +1,280 @@
// Copyright 2025 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package dumps
import (
"fmt"
"net"
"strings"
"sync"
"testing"
"time"
"github.com/dolthub/go-mysql-server/server"
"github.com/dolthub/go-mysql-server/sql"
"github.com/jackc/pgx/v5/pgproto3"
"github.com/stretchr/testify/require"
)
// ImportQueryError contains both a query and its associated error.
type ImportQueryError struct {
Query string
Error string
}
// InterceptArgs are the arguments that are passed to InterceptImportMessages.
type InterceptArgs struct {
DoltgresPort int
SkippedQueries []string
BreakpointQueries []string
TriggerBreakpoint func(string)
}
// passthroughArguments are the arguments that are passed to createPassthrough.
type passthroughArguments struct {
qeChan chan ImportQueryError
terminate *sync.WaitGroup
psqlConnBackend *pgproto3.Backend
doltgresConnFrontend *pgproto3.Frontend
triggerBreakpoint func(string)
skippedQueries []string
breakpointQueries []string
}
// InterceptImportMessages sits between PSQL and Doltgres, returning all error messages that are encountered. As we rely
// on PSQL to handle the import process, we normally wouldn't be able to associate error messages with queries, as this
// information is not returned by PSQL itself. Therefore, we create our own connection to Doltgres, and a server that
// PSQL listens to. We then forward everything from PSQL to Doltgres, while inspecting the messages as they come and go.
func InterceptImportMessages(t *testing.T, args InterceptArgs) (int, chan ImportQueryError) {
psqlPort, err := sql.GetEmptyPort()
require.NoError(t, err)
qeChan := make(chan ImportQueryError)
listener, err := server.NewListener("tcp", fmt.Sprintf("127.0.0.1:%d", psqlPort), "")
if err != nil {
t.Fatal(err)
return psqlPort, qeChan
}
timer := time.NewTimer(5 * time.Second)
timer.Stop()
go func() {
<-timer.C
_ = listener.Close()
}()
go func() {
for {
psqlConn, err := listener.Accept()
if err != nil {
return
}
timer.Stop()
terminate := &sync.WaitGroup{}
terminate.Add(1)
psqlConnBackend := pgproto3.NewBackend(psqlConn, psqlConn)
doltgresConn, err := (&net.Dialer{}).Dial("tcp", fmt.Sprintf("127.0.0.1:%d", args.DoltgresPort))
if err != nil {
fmt.Println(err)
return
}
doltgresConnFrontend := pgproto3.NewFrontend(doltgresConn, doltgresConn)
if err = handleStartup(t, psqlConnBackend, doltgresConnFrontend, psqlConn); err != nil {
fmt.Println(err)
return
}
createPassthrough(passthroughArguments{
qeChan: qeChan,
terminate: terminate,
psqlConnBackend: psqlConnBackend,
doltgresConnFrontend: doltgresConnFrontend,
triggerBreakpoint: args.TriggerBreakpoint,
skippedQueries: args.SkippedQueries,
breakpointQueries: args.BreakpointQueries,
})
terminate.Wait()
_ = psqlConn.Close()
_ = doltgresConn.Close()
timer.Reset(5 * time.Second)
}
}()
return psqlPort, qeChan
}
// handleStartup handles the startup messages.
func handleStartup(t *testing.T, psqlConnBackend *pgproto3.Backend, doltgresConnFrontend *pgproto3.Frontend, clientConn net.Conn) error {
StartupLoop:
for {
startupMessage, err := psqlConnBackend.ReceiveStartupMessage()
if err != nil {
return err
}
switch startupMessage := startupMessage.(type) {
case *pgproto3.SSLRequest:
if _, err = clientConn.Write([]byte{'N'}); err != nil {
return err
}
case *pgproto3.StartupMessage:
doltgresConnFrontend.Send(startupMessage)
if err = doltgresConnFrontend.Flush(); err != nil {
return err
}
response, err := doltgresConnFrontend.Receive()
if err != nil {
return err
}
if err = setAuthType(psqlConnBackend, response); err != nil {
return err
}
psqlConnBackend.Send(response)
if err = psqlConnBackend.Flush(); err != nil {
return err
}
break StartupLoop
case *pgproto3.GSSEncRequest:
// we don't support GSSAPI
_, err = clientConn.Write([]byte("N"))
if err != nil {
return err
}
default:
t.Fatalf("unexpected startup message: %v", startupMessage)
}
}
return nil
}
// setAuthType sets the client's authentication type depending on the message received from the server. This is
// necessary, as the client needs the proper context to know how to parse the returned messages.
func setAuthType(clientConnBackend *pgproto3.Backend, message pgproto3.BackendMessage) error {
switch message.(type) {
case *pgproto3.AuthenticationOk:
return clientConnBackend.SetAuthType(pgproto3.AuthTypeOk)
case *pgproto3.AuthenticationCleartextPassword:
return clientConnBackend.SetAuthType(pgproto3.AuthTypeCleartextPassword)
case *pgproto3.AuthenticationMD5Password:
return clientConnBackend.SetAuthType(pgproto3.AuthTypeMD5Password)
case *pgproto3.AuthenticationGSS:
return clientConnBackend.SetAuthType(pgproto3.AuthTypeGSS)
case *pgproto3.AuthenticationGSSContinue:
return clientConnBackend.SetAuthType(pgproto3.AuthTypeGSSCont)
case *pgproto3.AuthenticationSASL:
return clientConnBackend.SetAuthType(pgproto3.AuthTypeSASL)
case *pgproto3.AuthenticationSASLContinue:
return clientConnBackend.SetAuthType(pgproto3.AuthTypeSASLContinue)
case *pgproto3.AuthenticationSASLFinal:
return clientConnBackend.SetAuthType(pgproto3.AuthTypeSASLFinal)
default:
return nil
}
}
// createPassthrough creates the go routines that will read from and write to the connections.
func createPassthrough(args passthroughArguments) {
lastQuery := ""
writeMutex := &sync.Mutex{}
go func() {
defer args.terminate.Done()
for {
psqlMessage, err := args.psqlConnBackend.Receive()
if err != nil {
errStr := err.Error()
if errStr != "unexpected EOF" && !strings.HasSuffix(errStr, "use of closed network connection") {
fmt.Println(err)
}
return
}
switch msg := psqlMessage.(type) {
case *pgproto3.Query:
writeMutex.Lock()
if len(lastQuery) == 0 {
lastQuery = msg.String
}
writeMutex.Unlock()
for _, query := range args.skippedQueries {
if strings.HasPrefix(msg.String, query) {
// An empty query allows for the proper response messages to be sent.
msg.String = ";"
break
}
}
for _, query := range args.breakpointQueries {
if strings.HasPrefix(msg.String, query) {
args.triggerBreakpoint(msg.String)
break
}
}
case *pgproto3.Terminate:
return
}
args.doltgresConnFrontend.Send(psqlMessage)
if err = args.doltgresConnFrontend.Flush(); err != nil {
errStr := err.Error()
if errStr != "unexpected EOF" && !strings.HasSuffix(errStr, "use of closed network connection") {
fmt.Println(err)
}
return
}
}
}()
go func() {
for {
doltgresMessage, err := args.doltgresConnFrontend.Receive()
if err != nil {
errStr := err.Error()
if errStr != "unexpected EOF" &&
!strings.HasSuffix(errStr, "use of closed network connection") &&
!strings.HasSuffix(errStr, "An existing connection was forcibly closed by the remote host.") {
fmt.Println(err)
}
return
}
switch msg := doltgresMessage.(type) {
case *pgproto3.ErrorResponse:
writeMutex.Lock()
if len(lastQuery) == 0 {
args.qeChan <- ImportQueryError{
Query: "UNKNOWN QUERY HAS ERRORED",
Error: msg.Message,
}
} else {
args.qeChan <- ImportQueryError{
Query: lastQuery,
Error: msg.Message,
}
}
writeMutex.Unlock()
case *pgproto3.ReadyForQuery:
writeMutex.Lock()
lastQuery = ""
writeMutex.Unlock()
default:
if err = setAuthType(args.psqlConnBackend, doltgresMessage); err != nil {
fmt.Println(err)
return
}
}
args.psqlConnBackend.Send(doltgresMessage)
if err = args.psqlConnBackend.Flush(); err != nil {
errStr := err.Error()
if errStr != "unexpected EOF" &&
!strings.HasSuffix(errStr, "use of closed network connection") &&
!strings.HasSuffix(errStr, "An existing connection was forcibly closed by the remote host.") {
fmt.Println(err)
}
return
}
}
}()
}
+245
View File
@@ -0,0 +1,245 @@
// Copyright 2025 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
)
const (
query = `extension:sql pg_dump`
downloadCount = 110
)
// RepoName simply contains the name of the repository.
type RepoName struct {
FullName string `json:"full_name"`
}
// Item is a SQL file (hopefully) containing a pg_dump.
type Item struct {
Name string `json:"name"`
Path string `json:"path"`
HtmlURL string `json:"html_url"`
ContentsURL string `json:"url"`
Repository RepoName `json:"repository"`
}
// CodeSearchResult contains the result of a code search.
type CodeSearchResult struct {
TotalCount int `json:"total_count"`
IncompleteResults bool `json:"incomplete_results"`
Items []Item `json:"items"`
Message string `json:"message"` // Only used when there's an error
}
// ContentFile is all of the information about a SQL file, including how to retrieve it.
type ContentFile struct {
Type string `json:"type"`
Name string `json:"name"`
Path string `json:"path"`
SHA string `json:"sha"`
Size int64 `json:"size"`
HTMLURL string `json:"html_url"`
DownloadURL string `json:"download_url"`
}
func main() {
ctx := context.Background()
httpClient := &http.Client{Timeout: 30 * time.Second}
token := os.Getenv("GITHUB_TOKEN")
if len(token) == 0 {
fmt.Println("Must provide a GITHUB_TOKEN as an environment variable")
os.Exit(1)
}
_, currentFileLocation, _, ok := runtime.Caller(0)
if !ok {
fmt.Println("Unable to find the folder where this file is located")
os.Exit(1)
}
dumpsFolder := filepath.Clean(filepath.Join(filepath.Dir(currentFileLocation), "../sql"))
var saved int
page := 1
OuterLoop:
for {
remaining := downloadCount - saved
items, err := SearchCode(ctx, httpClient, token, page, min(50, remaining))
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if len(items) == 0 {
break
}
for _, item := range items {
cf, err := GetContent(ctx, httpClient, token, item.ContentsURL)
if err != nil {
fmt.Printf("warn: %s/%s: %v\n", item.Repository.FullName, item.Path, err)
continue
}
if cf.Type != "file" || cf.DownloadURL == "" {
continue
}
dest := filepath.Join(dumpsFolder, SanitizePath(item.Repository.FullName)+filepath.Ext(cf.Path))
if _, err = os.Stat(dest); err == nil {
continue
}
if err = DownloadFile(ctx, httpClient, item, cf.DownloadURL, dest); err != nil {
fmt.Printf("download error: %s -> %v\n", dest, err)
continue
}
fmt.Printf("saved: %s (%d bytes)\n", dest, cf.Size)
saved++
if saved >= downloadCount {
break OuterLoop
}
time.Sleep(6500 * time.Millisecond) // We sleep to mitigate rate limits
}
page++
}
}
// SearchCode executes the query against the API, returning all items that were found.
func SearchCode(ctx context.Context, hc *http.Client, token string, page int, perPage int) ([]Item, error) {
params := url.Values{}
params.Set("q", query)
params.Set("page", strconv.Itoa(page))
params.Set("per_page", strconv.Itoa(perPage))
req, _ := http.NewRequestWithContext(ctx, "GET", "https://api.github.com/search/code?"+params.Encode(), nil)
SetHeaders(req, token)
resp, err := hc.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if HandleRate(resp) {
return SearchCode(ctx, hc, token, page, perPage)
}
var sr CodeSearchResult
if err = json.NewDecoder(resp.Body).Decode(&sr); err != nil {
return nil, err
}
if resp.StatusCode != 200 {
if sr.Message != "" {
return nil, fmt.Errorf("search error: %s (HTTP %d)", sr.Message, resp.StatusCode)
}
return nil, fmt.Errorf("search error: HTTP %d", resp.StatusCode)
}
return sr.Items, nil
}
// GetContent gets the ContentFile from the given URL.
func GetContent(ctx context.Context, hc *http.Client, token string, contentsURL string) (*ContentFile, error) {
req, _ := http.NewRequestWithContext(ctx, "GET", contentsURL, nil)
SetHeaders(req, token)
resp, err := hc.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if HandleRate(resp) {
return GetContent(ctx, hc, token, contentsURL)
}
if resp.StatusCode != 200 {
b, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("contents error: HTTP %d: %s", resp.StatusCode, strings.TrimSpace(string(b)))
}
var cf ContentFile
if err = json.NewDecoder(resp.Body).Decode(&cf); err != nil {
return nil, err
}
return &cf, nil
}
// DownloadFile downloads the given SQL file to the destination.
func DownloadFile(ctx context.Context, hc *http.Client, item Item, rawURL string, dest string) error {
req, _ := http.NewRequestWithContext(ctx, "GET", rawURL, nil)
req.Header.Set("User-Agent", "gh-pg-dump-finder/1.0")
resp, err := hc.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("download HTTP %d", resp.StatusCode)
}
out, err := os.Create(dest)
if err != nil {
return err
}
defer out.Close()
_, _ = io.WriteString(out, fmt.Sprintf("-- Downloaded from: %s\n", item.HtmlURL))
_, err = io.Copy(out, resp.Body)
return err
}
// SetHeaders sets the appropriate headers for a request.
func SetHeaders(req *http.Request, token string) {
req.Header.Set("Accept", "application/vnd.github.v3+json")
req.Header.Set("User-Agent", "gh-pg-dump-finder/1.0")
req.Header.Set("Authorization", "Bearer "+token)
}
// HandleRate handles potential rate limits.
func HandleRate(resp *http.Response) bool {
if resp.StatusCode == 403 {
if ra := resp.Header.Get("Retry-After"); ra != "" {
if secs, _ := strconv.Atoi(ra); secs > 0 {
sleepTime := time.Duration(secs) * time.Second
fmt.Printf("rate limited (%s), retrying\n", sleepTime.String())
time.Sleep(sleepTime)
return true
}
}
if reset := resp.Header.Get("X-RateLimit-Reset"); reset != "" {
if ts, _ := strconv.ParseInt(reset, 10, 64); ts > 0 {
wait := time.Until(time.Unix(ts+5, 0))
if wait > 0 && wait < 5*time.Minute {
fmt.Printf("rate limited (%s), retrying\n", wait.String())
time.Sleep(wait)
return true
}
}
}
}
return false
}
// SanitizePath removes potentially invalid file system characters.
func SanitizePath(s string) string {
illegal := `<>:"\|/?*`
for _, r := range illegal {
s = strings.ReplaceAll(s, string(r), "_")
}
return s
}
@@ -0,0 +1,266 @@
-- Downloaded from: https://github.com/A-lang209/Salon-Appointment-Scheduler/blob/65664c1eca91624676853a6b56a8db25e807ed7c/salon.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.17 (Ubuntu 12.17-1.pgdg22.04+1)
-- Dumped by pg_dump version 12.17 (Ubuntu 12.17-1.pgdg22.04+1)
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;
DROP DATABASE salon;
--
-- Name: salon; Type: DATABASE; Schema: -; Owner: freecodecamp
--
CREATE DATABASE salon WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'C.UTF-8';
ALTER DATABASE salon OWNER TO freecodecamp;
\connect salon
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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: appointments; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.appointments (
appointment_id integer NOT NULL,
"time" character varying(255),
service_id integer,
customer_id integer
);
ALTER TABLE public.appointments OWNER TO freecodecamp;
--
-- Name: appointments_appointment_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.appointments_appointment_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.appointments_appointment_id_seq OWNER TO freecodecamp;
--
-- Name: appointments_appointment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.appointments_appointment_id_seq OWNED BY public.appointments.appointment_id;
--
-- Name: customers; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.customers (
customer_id integer NOT NULL,
phone character varying(30),
name character varying(255)
);
ALTER TABLE public.customers OWNER TO freecodecamp;
--
-- Name: customers_customer_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.customers_customer_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.customers_customer_id_seq OWNER TO freecodecamp;
--
-- Name: customers_customer_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.customers_customer_id_seq OWNED BY public.customers.customer_id;
--
-- Name: services; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.services (
service_id integer NOT NULL,
name character varying(255)
);
ALTER TABLE public.services OWNER TO freecodecamp;
--
-- Name: services_service_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.services_service_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.services_service_id_seq OWNER TO freecodecamp;
--
-- Name: services_service_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.services_service_id_seq OWNED BY public.services.service_id;
--
-- Name: appointments appointment_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.appointments ALTER COLUMN appointment_id SET DEFAULT nextval('public.appointments_appointment_id_seq'::regclass);
--
-- Name: customers customer_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.customers ALTER COLUMN customer_id SET DEFAULT nextval('public.customers_customer_id_seq'::regclass);
--
-- Name: services service_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.services ALTER COLUMN service_id SET DEFAULT nextval('public.services_service_id_seq'::regclass);
--
-- Data for Name: appointments; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
--
-- Data for Name: customers; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
--
-- Data for Name: services; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
INSERT INTO public.services VALUES (1, 'Haircut');
INSERT INTO public.services VALUES (2, 'Shave');
INSERT INTO public.services VALUES (3, 'Pedicure');
--
-- Name: appointments_appointment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.appointments_appointment_id_seq', 1, false);
--
-- Name: customers_customer_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.customers_customer_id_seq', 1, false);
--
-- Name: services_service_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.services_service_id_seq', 3, true);
--
-- Name: appointments appointments_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.appointments
ADD CONSTRAINT appointments_pkey PRIMARY KEY (appointment_id);
--
-- Name: customers customers_phone_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.customers
ADD CONSTRAINT customers_phone_key UNIQUE (phone);
--
-- Name: customers customers_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.customers
ADD CONSTRAINT customers_pkey PRIMARY KEY (customer_id);
--
-- Name: services services_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.services
ADD CONSTRAINT services_pkey PRIMARY KEY (service_id);
--
-- Name: appointments appointment_customer; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.appointments
ADD CONSTRAINT appointment_customer FOREIGN KEY (customer_id) REFERENCES public.customers(customer_id);
--
-- Name: appointments appointment_service; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.appointments
ADD CONSTRAINT appointment_service FOREIGN KEY (service_id) REFERENCES public.services(service_id);
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
+887
View File
@@ -0,0 +1,887 @@
-- Downloaded from: https://github.com/AlexTransit/venderctl/blob/5a4426d96e78edbf76b8157e42af2508dc7449bd/sql/db.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.15 (Debian 11.15-1.pgdg110+1)
-- Dumped by pg_dump version 11.1
-- Started on 2022-04-27 18:41:37
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 client_min_messages = warning;
SET row_security = off;
ALTER TABLE IF EXISTS ONLY public.trans DROP CONSTRAINT IF EXISTS trans_tax_job_id_fkey;
DROP TRIGGER IF EXISTS trans_tax ON public.trans;
DROP TRIGGER IF EXISTS tax_job_modified ON public.tax_job;
DROP TRIGGER IF EXISTS tax_job_maint_before ON public.tax_job;
DROP TRIGGER IF EXISTS tax_job_maint_after ON public.tax_job;
DROP INDEX IF EXISTS public.trans_executer;
DROP INDEX IF EXISTS public.tgchat_idx2;
DROP INDEX IF EXISTS public.tgchat_idx1;
DROP INDEX IF EXISTS public.tgchat_idx;
DROP INDEX IF EXISTS public.idx_trans_vmtime;
DROP INDEX IF EXISTS public.idx_trans_vmid_vmtime;
DROP INDEX IF EXISTS public.idx_tax_job_sched;
DROP INDEX IF EXISTS public.idx_tax_job_help;
DROP INDEX IF EXISTS public.idx_state_vmid_state_received;
DROP INDEX IF EXISTS public.idx_inventory_vmid_service;
DROP INDEX IF EXISTS public.idx_inventory_vmid_not_service;
DROP INDEX IF EXISTS public.idx_ingest_received;
DROP INDEX IF EXISTS public.idx_error_vmid_vmtime_code;
DROP INDEX IF EXISTS public.idx_catalog_vmid_code_name;
DROP INDEX IF EXISTS public.cashless_vmid_payment_id_order_id_key;
DROP INDEX IF EXISTS public.cashless_idx;
ALTER TABLE IF EXISTS ONLY public.tg_user DROP CONSTRAINT IF EXISTS tg_user_pkey;
ALTER TABLE IF EXISTS ONLY public.tax_job DROP CONSTRAINT IF EXISTS tax_job_pkey;
ALTER TABLE IF EXISTS ONLY public.state DROP CONSTRAINT IF EXISTS state_vmid_key;
ALTER TABLE IF EXISTS ONLY public.robot DROP CONSTRAINT IF EXISTS robot_serial_num_key;
ALTER TABLE IF EXISTS ONLY public.robot DROP CONSTRAINT IF EXISTS "robot-key";
ALTER TABLE IF EXISTS public.tax_job ALTER COLUMN id DROP DEFAULT;
DROP SEQUENCE IF EXISTS public.tg_user_user_id_seq;
DROP TABLE IF EXISTS public.tg_user;
DROP TABLE IF EXISTS public.tg_chat;
DROP SEQUENCE IF EXISTS public.tax_job_id_seq;
DROP VIEW IF EXISTS public.tax_job_help;
DROP TABLE IF EXISTS public.state;
DROP TABLE IF EXISTS public.robot;
DROP TABLE IF EXISTS public.old_state;
DROP TABLE IF EXISTS public.inventory;
DROP TABLE IF EXISTS public.ingest;
DROP TABLE IF EXISTS public.error;
DROP TABLE IF EXISTS public.catalog;
DROP TABLE IF EXISTS public.cashless;
DROP FUNCTION IF EXISTS public.vmstate(s integer);
DROP FUNCTION IF EXISTS public.trans_tax_trigger();
DROP FUNCTION IF EXISTS public.tax_job_trans(t public.trans);
DROP TABLE IF EXISTS public.trans;
DROP FUNCTION IF EXISTS public.tax_job_take(arg_worker text);
DROP TABLE IF EXISTS public.tax_job;
DROP FUNCTION IF EXISTS public.tax_job_modified();
DROP FUNCTION IF EXISTS public.tax_job_maint_before();
DROP FUNCTION IF EXISTS public.tax_job_maint_after();
DROP FUNCTION IF EXISTS public.state_update(arg_vmid integer, arg_state integer);
DROP FUNCTION IF EXISTS public.connect_update(arg_vmid integer, arg_connect boolean);
DROP TYPE IF EXISTS public.tax_job_state;
DROP TYPE IF EXISTS public.cashless_state;
DROP EXTENSION IF EXISTS hstore;
--
-- TOC entry 2 (class 3079 OID 24642)
-- Name: hstore; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
--
-- TOC entry 3092 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
--
-- TOC entry 692 (class 1247 OID 65591)
-- Name: cashless_state; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.cashless_state AS ENUM (
'order_start',
'order_prepay',
'order_complete',
'order_cancel'
);
--
-- TOC entry 707 (class 1247 OID 26134)
-- Name: tax_job_state; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.tax_job_state AS ENUM (
'sched',
'busy',
'final',
'help'
);
--
-- TOC entry 294 (class 1255 OID 55071)
-- Name: connect_update(integer, boolean); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.connect_update(arg_vmid integer, arg_connect boolean) RETURNS integer
LANGUAGE plpgsql
AS '
BEGIN
INSERT INTO state (vmid, state, received, connected, contime) VALUES (arg_vmid, 0, CURRENT_TIMESTAMP, arg_connect, CURRENT_TIMESTAMP)
ON CONFLICT (vmid) DO UPDATE
SET connected = excluded.connected, contime = CURRENT_TIMESTAMP;
return null;
END;
';
--
-- TOC entry 290 (class 1255 OID 25797)
-- Name: state_update(integer, integer); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.state_update(arg_vmid integer, arg_state integer) RETURNS integer
LANGUAGE plpgsql
AS '
DECLARE
old_state int4 = NULL;
BEGIN
SELECT
state INTO old_state
FROM
state
WHERE
vmid = arg_vmid
LIMIT 1
FOR UPDATE;
INSERT INTO state (vmid, state, received)
VALUES (arg_vmid, arg_state, CURRENT_TIMESTAMP)
ON CONFLICT (vmid)
DO UPDATE SET
state = excluded.state, received = excluded.received;
RETURN old_state;
END;
';
--
-- TOC entry 291 (class 1255 OID 26171)
-- Name: tax_job_maint_after(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.tax_job_maint_after() RETURNS trigger
LANGUAGE plpgsql
AS '
BEGIN
CASE new.state
WHEN ''final'' THEN
NOTIFY tax_job_final;
WHEN ''help'' THEN
NOTIFY tax_job_help;
WHEN ''sched'' THEN
NOTIFY tax_job_sched;
ELSE
NULL;
END CASE;
RETURN NEW;
END;
';
--
-- TOC entry 292 (class 1255 OID 26173)
-- Name: tax_job_maint_before(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.tax_job_maint_before() RETURNS trigger
LANGUAGE plpgsql
AS '
BEGIN
IF new.state = ''final'' THEN
new.scheduled = NULL;
END IF;
RETURN NEW;
END;
';
--
-- TOC entry 293 (class 1255 OID 26175)
-- Name: tax_job_modified(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.tax_job_modified() RETURNS trigger
LANGUAGE plpgsql
AS '
BEGIN
new.modified := CURRENT_TIMESTAMP;
RETURN NEW;
END;
';
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 209 (class 1259 OID 26219)
-- Name: tax_job; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.tax_job (
id bigint NOT NULL,
state public.tax_job_state NOT NULL,
created timestamp with time zone NOT NULL,
modified timestamp with time zone NOT NULL,
scheduled timestamp with time zone,
worker text,
processor text,
ext_id text,
data jsonb,
gross integer,
notes text[],
ops jsonb,
CONSTRAINT tax_job_check CHECK ((NOT ((state = 'sched'::public.tax_job_state) AND (scheduled IS NULL)))),
CONSTRAINT tax_job_check1 CHECK ((NOT ((state = 'busy'::public.tax_job_state) AND (worker IS NULL))))
);
--
-- TOC entry 295 (class 1255 OID 26249)
-- Name: tax_job_take(text); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.tax_job_take(arg_worker text) RETURNS SETOF public.tax_job
LANGUAGE sql
AS '
UPDATE
tax_job
SET
state = ''busy'',
worker = arg_worker
WHERE
state = ''sched''
AND scheduled <= CURRENT_TIMESTAMP
AND id = (
SELECT
id
FROM
tax_job
WHERE
state = ''sched''
AND scheduled <= CURRENT_TIMESTAMP
ORDER BY
scheduled,
modified
LIMIT 1
FOR UPDATE
SKIP LOCKED)
RETURNING
*;
';
--
-- TOC entry 210 (class 1259 OID 26232)
-- Name: trans; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.trans (
vmid integer NOT NULL,
vmtime timestamp with time zone,
received timestamp with time zone NOT NULL,
menu_code text NOT NULL,
options integer[],
price integer NOT NULL,
method integer NOT NULL,
tax_job_id bigint,
executer bigint,
exeputer_type integer,
executer_str text
);
--
-- TOC entry 296 (class 1255 OID 26250)
-- Name: tax_job_trans(public.trans); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.tax_job_trans(t public.trans) RETURNS public.tax_job
LANGUAGE plpgsql
AS '
# print_strict_params ON
DECLARE
tjd jsonb;
ops jsonb;
tj tax_job;
name text;
BEGIN
-- lock trans row
PERFORM
1
FROM
trans
WHERE (vmid, vmtime) = (t.vmid,
t.vmtime)
LIMIT 1
FOR UPDATE;
-- if trans already has tax_job assigned, just return it
IF t.tax_job_id IS NOT NULL THEN
SELECT
* INTO STRICT tj
FROM
tax_job
WHERE
id = t.tax_job_id;
RETURN tj;
END IF;
-- op code to human friendly name via catalog
SELECT
catalog.name INTO name
FROM
catalog
WHERE (vmid, code) = (t.vmid,
t.menu_code);
IF NOT found THEN
name := ''#'' || t.menu_code;
END IF;
ops := jsonb_build_array (jsonb_build_object(''vmid'', t.vmid, ''time'', t.vmtime, ''name'', name, ''code'', t.menu_code, ''amount'', 1, ''price'', t.price, ''method'', t.method));
INSERT INTO tax_job (state, created, modified, scheduled, processor, ops, gross)
VALUES (''sched'', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ''ru2019'', ops, t.price)
RETURNING
* INTO STRICT tj;
UPDATE
trans
SET
tax_job_id = tj.id
WHERE (vmid, vmtime) = (t.vmid,
t.vmtime);
RETURN tj;
END;
';
--
-- TOC entry 289 (class 1255 OID 26177)
-- Name: trans_tax_trigger(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.trans_tax_trigger() RETURNS trigger
LANGUAGE plpgsql
AS '
BEGIN
IF (NEW.vmid = (SELECT vmid from robot where robot.vmid = NEW.vmid and robot.work = TRUE) and (NEW.method = 1 or NEW.method = 2)) THEN
PERFORM
tax_job_trans (new);
END IF;
RETURN new;
END;
';
--
-- TOC entry 297 (class 1255 OID 26492)
-- Name: vmstate(integer); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.vmstate(s integer) RETURNS text
LANGUAGE sql IMMUTABLE STRICT
AS '
-- TODO generate from tele.proto
-- Invalid = 0;
-- Boot = 1;
-- Nominal = 2;
-- Disconnected = 3;
-- Problem = 4;
-- Service = 5;
-- Lock = 6;
SELECT
CASE WHEN s = 0 THEN
''Invalid''
WHEN s = 1 THEN
''Boot''
WHEN s = 2 THEN
''Nominal''
WHEN s = 3 THEN
''Disconnected''
WHEN s = 4 THEN
''Problem''
WHEN s = 5 THEN
''Service''
WHEN s = 6 THEN
''Lock''
ELSE
''unknown:'' || s
END
';
--
-- TOC entry 219 (class 1259 OID 65639)
-- Name: cashless; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.cashless (
state public.cashless_state DEFAULT 'order_start'::public.cashless_state NOT NULL,
vmid integer NOT NULL,
create_date timestamp with time zone NOT NULL,
credit_date timestamp with time zone,
finish_date timestamp with time zone,
payment_id character varying(20) NOT NULL,
order_id character varying NOT NULL,
amount integer NOT NULL,
credited integer DEFAULT 0 NOT NULL,
bank_commission integer DEFAULT 0 NOT NULL,
terminal text
);
ALTER TABLE ONLY public.cashless ALTER COLUMN credit_date SET STATISTICS 0;
ALTER TABLE ONLY public.cashless ALTER COLUMN payment_id SET STATISTICS 0;
ALTER TABLE ONLY public.cashless ALTER COLUMN credited SET STATISTICS 0;
--
-- TOC entry 212 (class 1259 OID 26503)
-- Name: catalog; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.catalog (
vmid integer NOT NULL,
code text NOT NULL,
name text NOT NULL
);
--
-- TOC entry 206 (class 1259 OID 25437)
-- Name: error; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.error (
vmid integer NOT NULL,
vmtime timestamp with time zone NOT NULL,
received timestamp with time zone NOT NULL,
code integer,
message text NOT NULL,
count integer,
app_version text
);
--
-- TOC entry 205 (class 1259 OID 25417)
-- Name: ingest; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.ingest (
received timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
vmid integer NOT NULL,
done boolean DEFAULT false NOT NULL,
raw bytea NOT NULL
);
--
-- TOC entry 207 (class 1259 OID 25482)
-- Name: inventory; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.inventory (
vmid integer NOT NULL,
at_service boolean NOT NULL,
vmtime timestamp with time zone NOT NULL,
received timestamp with time zone NOT NULL,
inventory public.hstore,
cashbox_bill public.hstore,
cashbox_coin public.hstore,
change_bill public.hstore,
change_coin public.hstore
);
--
-- TOC entry 214 (class 1259 OID 55050)
-- Name: old_state; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.old_state (
state integer
);
--
-- TOC entry 213 (class 1259 OID 26578)
-- Name: robot; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.robot (
vmid integer NOT NULL,
vmnum integer NOT NULL,
description text,
location text,
bunkers public.hstore,
"mobile-number" numeric(10,0),
serial_num numeric(7,0) NOT NULL,
work boolean DEFAULT true NOT NULL,
in_robo public.hstore,
to_robo public.hstore
);
--
-- TOC entry 3093 (class 0 OID 0)
-- Dependencies: 213
-- Name: COLUMN robot.in_robo; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.robot.in_robo IS 'inventoiry inside robo';
--
-- TOC entry 215 (class 1259 OID 55059)
-- Name: state; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.state (
vmid integer NOT NULL,
state integer NOT NULL,
received timestamp with time zone NOT NULL,
connected boolean DEFAULT false NOT NULL,
contime timestamp with time zone DEFAULT now() NOT NULL
);
--
-- TOC entry 211 (class 1259 OID 26245)
-- Name: tax_job_help; Type: VIEW; Schema: public; Owner: -
--
CREATE VIEW public.tax_job_help AS
SELECT tax_job.id,
tax_job.state,
tax_job.created,
tax_job.modified,
tax_job.scheduled,
tax_job.worker,
tax_job.processor,
tax_job.ext_id,
tax_job.data,
tax_job.gross,
tax_job.notes
FROM public.tax_job
WHERE (tax_job.state = 'help'::public.tax_job_state)
ORDER BY tax_job.modified;
--
-- TOC entry 208 (class 1259 OID 26217)
-- Name: tax_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.tax_job_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- TOC entry 3094 (class 0 OID 0)
-- Dependencies: 208
-- Name: tax_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.tax_job_id_seq OWNED BY public.tax_job.id;
--
-- TOC entry 218 (class 1259 OID 65014)
-- Name: tg_chat; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.tg_chat (
create_date timestamp(0) without time zone DEFAULT now() NOT NULL,
messageid integer NOT NULL,
fromid bigint NOT NULL,
toid bigint NOT NULL,
date integer NOT NULL,
text text,
changedate integer,
changetext text
);
ALTER TABLE ONLY public.tg_chat ALTER COLUMN messageid SET STATISTICS 0;
ALTER TABLE ONLY public.tg_chat ALTER COLUMN fromid SET STATISTICS 0;
ALTER TABLE ONLY public.tg_chat ALTER COLUMN toid SET STATISTICS 0;
ALTER TABLE ONLY public.tg_chat ALTER COLUMN text SET STATISTICS 0;
--
-- TOC entry 217 (class 1259 OID 64971)
-- Name: tg_user; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.tg_user (
ban boolean DEFAULT false,
userid bigint NOT NULL,
name text,
firstname text,
lastname text,
phonenumber text,
balance integer,
credit integer,
registerdate integer,
diskont integer DEFAULT 3
);
ALTER TABLE ONLY public.tg_user ALTER COLUMN name SET STATISTICS 0;
ALTER TABLE ONLY public.tg_user ALTER COLUMN phonenumber SET STATISTICS 0;
--
-- TOC entry 216 (class 1259 OID 64969)
-- Name: tg_user_user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.tg_user_user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- TOC entry 3095 (class 0 OID 0)
-- Dependencies: 216
-- Name: tg_user_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.tg_user_user_id_seq OWNED BY public.tg_user.userid;
--
-- TOC entry 2922 (class 2604 OID 26222)
-- Name: tax_job id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.tax_job ALTER COLUMN id SET DEFAULT nextval('public.tax_job_id_seq'::regclass);
--
-- TOC entry 2947 (class 2606 OID 26586)
-- Name: robot robot-key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.robot
ADD CONSTRAINT "robot-key" PRIMARY KEY (vmid);
--
-- TOC entry 2949 (class 2606 OID 26588)
-- Name: robot robot_serial_num_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.robot
ADD CONSTRAINT robot_serial_num_key UNIQUE (serial_num);
--
-- TOC entry 2952 (class 2606 OID 55075)
-- Name: state state_vmid_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.state
ADD CONSTRAINT state_vmid_key UNIQUE (vmid);
--
-- TOC entry 2941 (class 2606 OID 26229)
-- Name: tax_job tax_job_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.tax_job
ADD CONSTRAINT tax_job_pkey PRIMARY KEY (id);
--
-- TOC entry 2954 (class 2606 OID 64984)
-- Name: tg_user tg_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.tg_user
ADD CONSTRAINT tg_user_pkey PRIMARY KEY (userid);
--
-- TOC entry 2958 (class 1259 OID 65648)
-- Name: cashless_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX cashless_idx ON public.cashless USING btree (payment_id, order_id);
--
-- TOC entry 2959 (class 1259 OID 65649)
-- Name: cashless_vmid_payment_id_order_id_key; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX cashless_vmid_payment_id_order_id_key ON public.cashless USING btree (vmid, payment_id, order_id);
--
-- TOC entry 2945 (class 1259 OID 26509)
-- Name: idx_catalog_vmid_code_name; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX idx_catalog_vmid_code_name ON public.catalog USING btree (vmid, code, name);
--
-- TOC entry 2935 (class 1259 OID 26132)
-- Name: idx_error_vmid_vmtime_code; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_error_vmid_vmtime_code ON public.error USING btree (vmid, vmtime DESC) INCLUDE (code);
--
-- TOC entry 2934 (class 1259 OID 26128)
-- Name: idx_ingest_received; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_ingest_received ON public.ingest USING btree (received) WHERE (NOT done);
--
-- TOC entry 2936 (class 1259 OID 26131)
-- Name: idx_inventory_vmid_not_service; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX idx_inventory_vmid_not_service ON public.inventory USING btree (vmid) WITH (fillfactor='10') WHERE (NOT at_service);
--
-- TOC entry 2937 (class 1259 OID 26130)
-- Name: idx_inventory_vmid_service; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX idx_inventory_vmid_service ON public.inventory USING btree (vmid) WITH (fillfactor='10') WHERE at_service;
--
-- TOC entry 2950 (class 1259 OID 55062)
-- Name: idx_state_vmid_state_received; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX idx_state_vmid_state_received ON public.state USING btree (vmid, state, received) WITH (fillfactor='10');
--
-- TOC entry 2938 (class 1259 OID 26231)
-- Name: idx_tax_job_help; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_tax_job_help ON public.tax_job USING btree (modified) WHERE (state = 'help'::public.tax_job_state);
--
-- TOC entry 2939 (class 1259 OID 26230)
-- Name: idx_tax_job_sched; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_tax_job_sched ON public.tax_job USING btree (scheduled, modified) WHERE (state = 'sched'::public.tax_job_state);
--
-- TOC entry 2942 (class 1259 OID 26244)
-- Name: idx_trans_vmid_vmtime; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX idx_trans_vmid_vmtime ON public.trans USING btree (vmid, vmtime);
--
-- TOC entry 2943 (class 1259 OID 26243)
-- Name: idx_trans_vmtime; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_trans_vmtime ON public.trans USING btree (vmtime);
--
-- TOC entry 2955 (class 1259 OID 65021)
-- Name: tgchat_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX tgchat_idx ON public.tg_chat USING btree (messageid, fromid, toid, date);
--
-- TOC entry 2956 (class 1259 OID 65022)
-- Name: tgchat_idx1; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX tgchat_idx1 ON public.tg_chat USING btree (fromid);
--
-- TOC entry 2957 (class 1259 OID 65023)
-- Name: tgchat_idx2; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX tgchat_idx2 ON public.tg_chat USING btree (toid);
--
-- TOC entry 2944 (class 1259 OID 64901)
-- Name: trans_executer; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX trans_executer ON public.trans USING btree (executer);
--
-- TOC entry 2961 (class 2620 OID 26251)
-- Name: tax_job tax_job_maint_after; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER tax_job_maint_after AFTER INSERT OR UPDATE ON public.tax_job FOR EACH ROW EXECUTE PROCEDURE public.tax_job_maint_after();
--
-- TOC entry 2962 (class 2620 OID 26252)
-- Name: tax_job tax_job_maint_before; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER tax_job_maint_before BEFORE INSERT OR UPDATE ON public.tax_job FOR EACH ROW EXECUTE PROCEDURE public.tax_job_maint_before();
--
-- TOC entry 2963 (class 2620 OID 26253)
-- Name: tax_job tax_job_modified; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER tax_job_modified BEFORE UPDATE ON public.tax_job FOR EACH ROW WHEN (((new.ext_id IS DISTINCT FROM old.ext_id) OR (new.data IS DISTINCT FROM old.data) OR (new.notes IS DISTINCT FROM old.notes))) EXECUTE PROCEDURE public.tax_job_modified();
--
-- TOC entry 2964 (class 2620 OID 26254)
-- Name: trans trans_tax; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER trans_tax AFTER INSERT ON public.trans FOR EACH ROW EXECUTE PROCEDURE public.trans_tax_trigger();
--
-- TOC entry 2960 (class 2606 OID 26238)
-- Name: trans trans_tax_job_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.trans
ADD CONSTRAINT trans_tax_job_id_fkey FOREIGN KEY (tax_job_id) REFERENCES public.tax_job(id) ON UPDATE RESTRICT ON DELETE SET NULL;
-- Completed on 2022-04-27 18:41:38
--
-- PostgreSQL database dump complete
--
+174
View File
@@ -0,0 +1,174 @@
-- Downloaded from: https://github.com/AliiAhmadi/PostScan/blob/27620d20ed609904a16cef08af33ed8f16b984f9/backup.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.3
-- Dumped by pg_dump version 16.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;
--
-- Name: malicious_function(); Type: FUNCTION; Schema: public; Owner: testuser
--
CREATE FUNCTION public.malicious_function() RETURNS void
LANGUAGE plpgsql SECURITY DEFINER
AS $$
BEGIN
PERFORM pg_sleep(10);
END;
$$;
ALTER FUNCTION public.malicious_function() OWNER TO testuser;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: test; DROP TABLE users;; Type: TABLE; Schema: public; Owner: testuser
--
CREATE TABLE public."test; DROP TABLE users;" (
id integer NOT NULL
);
ALTER TABLE public."test; DROP TABLE users;" OWNER TO testuser;
--
-- Name: test; DROP TABLE users;_id_seq; Type: SEQUENCE; Schema: public; Owner: testuser
--
CREATE SEQUENCE public."test; DROP TABLE users;_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."test; DROP TABLE users;_id_seq" OWNER TO testuser;
--
-- Name: test; DROP TABLE users;_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: testuser
--
ALTER SEQUENCE public."test; DROP TABLE users;_id_seq" OWNED BY public."test; DROP TABLE users;".id;
--
-- Name: test_table; Type: TABLE; Schema: public; Owner: testuser
--
CREATE TABLE public.test_table (
id integer NOT NULL
);
ALTER TABLE public.test_table OWNER TO testuser;
--
-- Name: test_table_id_seq; Type: SEQUENCE; Schema: public; Owner: testuser
--
CREATE SEQUENCE public.test_table_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.test_table_id_seq OWNER TO testuser;
--
-- Name: test_table_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: testuser
--
ALTER SEQUENCE public.test_table_id_seq OWNED BY public.test_table.id;
--
-- Name: test; DROP TABLE users; id; Type: DEFAULT; Schema: public; Owner: testuser
--
ALTER TABLE ONLY public."test; DROP TABLE users;" ALTER COLUMN id SET DEFAULT nextval('public."test; DROP TABLE users;_id_seq"'::regclass);
--
-- Name: test_table id; Type: DEFAULT; Schema: public; Owner: testuser
--
ALTER TABLE ONLY public.test_table ALTER COLUMN id SET DEFAULT nextval('public.test_table_id_seq'::regclass);
--
-- Data for Name: test; DROP TABLE users;; Type: TABLE DATA; Schema: public; Owner: testuser
--
COPY public."test; DROP TABLE users;" (id) FROM stdin;
\.
--
-- Data for Name: test_table; Type: TABLE DATA; Schema: public; Owner: testuser
--
COPY public.test_table (id) FROM stdin;
\.
--
-- Name: test; DROP TABLE users;_id_seq; Type: SEQUENCE SET; Schema: public; Owner: testuser
--
SELECT pg_catalog.setval('public."test; DROP TABLE users;_id_seq"', 1, false);
--
-- Name: test_table_id_seq; Type: SEQUENCE SET; Schema: public; Owner: testuser
--
SELECT pg_catalog.setval('public.test_table_id_seq', 1, false);
--
-- Name: test_table test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: testuser
--
ALTER TABLE ONLY public.test_table
ADD CONSTRAINT test_table_pkey PRIMARY KEY (id);
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: pg_database_owner
--
GRANT ALL ON SCHEMA public TO testuser;
--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: postgres
--
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO testuser;
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,96 @@
-- Downloaded from: https://github.com/Ansh-Rathod/Musive-backend-2.0/blob/eb320d80d2fa07283bb4ab9351581f4c8757bcad/schema.sql
create table Users(
id serial primary key,
username varchar(28) not null unique,
passhash varchar not null
);
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
create table public."Artists"(
id integer unique not null,
username text not null unique,
display_name text not null,
avatar jsonb,
gender varchar,
PRIMARY KEY(id)
);
create table public."Tracks"(
id integer unique not null,
user_id integer not null,
tags text[] not null DEFAULT '{}',
moods text[] not null DEFAULT '{}',
genres text[] not null DEFAULT '{}',
movements text[] not null DEFAULT '{}',
keywords text not null,
duration float not null,
track_name text not null,
download_url text not null,
src text not null,
cover_image jsonb,
PRIMARY KEY(id)
);
alter table if exists songs
add constraint user_id_fk FOREIGN KEY (user_id) REFERENCES artists(id)
match full on update CASCADE on delete CASCADE;
create table public."Liked"(
id serial primary key,
track_id integer not null,
username varchar(28) not null
);
alter table public."Liked" add constraint track_id FOREIGN KEY(track_id)
REFERENCES public."Tracks"(id) match full on update CASCADE on delete cascade;
alter table public."Liked" add constraint user_id FOREIGN KEY(username)
REFERENCES public."Users"(username) match full on update CASCADE on delete cascade;
create table public."Collections"(
id uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
name text not null,
username varchar(28) not null,
total_tracks integer DEFAULT 0
);
alter table public."Collections" add constraint user_id FOREIGN KEY(username)
REFERENCES public."Users"(username) match full on update CASCADE on delete cascade;
create table public."CollectionItems"(
collection_id uuid not null,
track_id integer not null
);
alter table public."CollectionItems" add constraint collection_id_fk FOREIGN KEY(collection_id)
REFERENCES public."Collections"(id) match full on update CASCADE on delete cascade;
alter table public."CollectionItems" add constraint track_id_fk FOREIGN KEY(track_id)
REFERENCES public."Tracks"(id) match full on update CASCADE on delete cascade;
CREATE OR REPLACE FUNCTION update_collections()
RETURNS trigger AS $$
DECLARE
BEGIN
IF TG_OP = 'INSERT' THEN
EXECUTE 'update public."Collections" set total_tracks=total_tracks+1 where id = $1;'
USING NEW.collection_id;
END IF;
IF TG_OP = 'DELETE' THEN
EXECUTE 'update public."Collections" set total_tracks=total_tracks-1 where id = $1;'
USING OLD.collection_id;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER update_collection
AFTER INSERT OR DELETE ON public."CollectionItems"
FOR EACH ROW EXECUTE PROCEDURE update_collections();
-- pg_dump -U postgres -h containers-us-west-63.railway.app -p 7771 railway >> sqlfile.sql
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,89 @@
-- Downloaded from: https://github.com/Boluwatife-AJB/backend-in-node/blob/302739ec5fb1880b77d9cb51636834bdacff16ed/sample.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 15.8 (Homebrew)
-- Dumped by pg_dump version 15.8 (Homebrew)
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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: companies; Type: TABLE; Schema: public; Owner: USER
--
CREATE TABLE public.companies (
id uuid NOT NULL,
name character varying
);
ALTER TABLE public.companies OWNER TO "USER";
--
-- Name: employees; Type: TABLE; Schema: public; Owner: USER
--
CREATE TABLE public.employees (
id uuid NOT NULL,
first_name character varying,
last_name character varying,
email character varying
);
ALTER TABLE public.employees OWNER TO "USER";
--
-- Data for Name: companies; Type: TABLE DATA; Schema: public; Owner: USER
--
COPY public.companies (id, name) FROM stdin;
f5c41428-5f90-4ca6-b167-9c6f5a41bae0 valhalla
7874572b-e4ca-4add-958e-3f611649c9bf ghost road
\.
--
-- Data for Name: employees; Type: TABLE DATA; Schema: public; Owner: USER
--
COPY public.employees (id, first_name, last_name, email) FROM stdin;
ce4b3817-2ea9-4f4c-9760-8ad30aa807be max maximus max@valhallah.org
ce4b3817-2ea9-4f4c-9760-8ad30aa347be mcDonalds williams williams@ghost-road.org
\.
--
-- Name: companies companies_pkey; Type: CONSTRAINT; Schema: public; Owner: USER
--
ALTER TABLE ONLY public.companies
ADD CONSTRAINT companies_pkey PRIMARY KEY (id);
--
-- Name: employees employees_pkey; Type: CONSTRAINT; Schema: public; Owner: USER
--
ALTER TABLE ONLY public.employees
ADD CONSTRAINT employees_pkey PRIMARY KEY (id);
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,741 @@
-- Downloaded from: https://github.com/Chris-Merced/Classic-Messenger-App-Backend/blob/830ae3a7451ff23d2d41943f7a727008e525e190/schema.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.9 (Ubuntu 16.9-0ubuntu0.24.04.1)
-- Dumped by pg_dump version 16.9 (Ubuntu 16.9-0ubuntu0.24.04.1)
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;
--
-- Name: _heroku; Type: SCHEMA; Schema: -; Owner: chris
--
CREATE SCHEMA _heroku;
ALTER SCHEMA _heroku OWNER TO chris;
--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
--
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed';
--
-- Name: create_ext(); Type: FUNCTION; Schema: _heroku; Owner: chris
--
CREATE FUNCTION _heroku.create_ext() RETURNS event_trigger
LANGUAGE plpgsql SECURITY DEFINER
AS $$
DECLARE
schemaname TEXT;
databaseowner TEXT;
r RECORD;
BEGIN
IF tg_tag = 'CREATE EXTENSION' and current_user != 'rds_superuser' THEN
FOR r IN SELECT * FROM pg_event_trigger_ddl_commands()
LOOP
CONTINUE WHEN r.command_tag != 'CREATE EXTENSION' OR r.object_type != 'extension';
schemaname = (
SELECT n.nspname
FROM pg_catalog.pg_extension AS e
INNER JOIN pg_catalog.pg_namespace AS n
ON e.extnamespace = n.oid
WHERE e.oid = r.objid
);
databaseowner = (
SELECT pg_catalog.pg_get_userbyid(d.datdba)
FROM pg_catalog.pg_database d
WHERE d.datname = current_database()
);
--RAISE NOTICE 'Record for event trigger %, objid: %,tag: %, current_user: %, schema: %, database_owenr: %', r.object_identity, r.objid, tg_tag, current_user, schemaname, databaseowner;
IF r.object_identity = 'address_standardizer_data_us' THEN
PERFORM _heroku.grant_table_if_exists(schemaname, 'SELECT, UPDATE, INSERT, DELETE', databaseowner, 'us_gaz');
PERFORM _heroku.grant_table_if_exists(schemaname, 'SELECT, UPDATE, INSERT, DELETE', databaseowner, 'us_lex');
PERFORM _heroku.grant_table_if_exists(schemaname, 'SELECT, UPDATE, INSERT, DELETE', databaseowner, 'us_rules');
ELSIF r.object_identity = 'amcheck' THEN
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.bt_index_check TO %I;', schemaname, databaseowner);
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.bt_index_parent_check TO %I;', schemaname, databaseowner);
ELSIF r.object_identity = 'dict_int' THEN
EXECUTE format('ALTER TEXT SEARCH DICTIONARY %I.intdict OWNER TO %I;', schemaname, databaseowner);
ELSIF r.object_identity = 'pg_partman' THEN
PERFORM _heroku.grant_table_if_exists(schemaname, 'SELECT, UPDATE, INSERT, DELETE', databaseowner, 'part_config');
PERFORM _heroku.grant_table_if_exists(schemaname, 'SELECT, UPDATE, INSERT, DELETE', databaseowner, 'part_config_sub');
PERFORM _heroku.grant_table_if_exists(schemaname, 'SELECT, UPDATE, INSERT, DELETE', databaseowner, 'custom_time_partitions');
ELSIF r.object_identity = 'pg_stat_statements' THEN
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.pg_stat_statements_reset TO %I;', schemaname, databaseowner);
ELSIF r.object_identity = 'postgis' THEN
PERFORM _heroku.postgis_after_create();
ELSIF r.object_identity = 'postgis_raster' THEN
PERFORM _heroku.postgis_after_create();
PERFORM _heroku.grant_table_if_exists(schemaname, 'SELECT', databaseowner, 'raster_columns');
PERFORM _heroku.grant_table_if_exists(schemaname, 'SELECT', databaseowner, 'raster_overviews');
ELSIF r.object_identity = 'postgis_topology' THEN
PERFORM _heroku.postgis_after_create();
EXECUTE format('GRANT USAGE ON SCHEMA topology TO %I;', databaseowner);
EXECUTE format('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA topology TO %I;', databaseowner);
PERFORM _heroku.grant_table_if_exists('topology', 'SELECT, UPDATE, INSERT, DELETE', databaseowner);
EXECUTE format('GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA topology TO %I;', databaseowner);
ELSIF r.object_identity = 'postgis_tiger_geocoder' THEN
PERFORM _heroku.postgis_after_create();
EXECUTE format('GRANT USAGE ON SCHEMA tiger TO %I;', databaseowner);
EXECUTE format('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA tiger TO %I;', databaseowner);
PERFORM _heroku.grant_table_if_exists('tiger', 'SELECT, UPDATE, INSERT, DELETE', databaseowner);
EXECUTE format('GRANT USAGE ON SCHEMA tiger_data TO %I;', databaseowner);
EXECUTE format('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA tiger_data TO %I;', databaseowner);
PERFORM _heroku.grant_table_if_exists('tiger_data', 'SELECT, UPDATE, INSERT, DELETE', databaseowner);
END IF;
END LOOP;
END IF;
END;
$$;
ALTER FUNCTION _heroku.create_ext() OWNER TO chris;
--
-- Name: drop_ext(); Type: FUNCTION; Schema: _heroku; Owner: chris
--
CREATE FUNCTION _heroku.drop_ext() RETURNS event_trigger
LANGUAGE plpgsql SECURITY DEFINER
AS $$
DECLARE
schemaname TEXT;
databaseowner TEXT;
r RECORD;
BEGIN
IF tg_tag = 'DROP EXTENSION' and current_user != 'rds_superuser' THEN
FOR r IN SELECT * FROM pg_event_trigger_dropped_objects()
LOOP
CONTINUE WHEN r.object_type != 'extension';
databaseowner = (
SELECT pg_catalog.pg_get_userbyid(d.datdba)
FROM pg_catalog.pg_database d
WHERE d.datname = current_database()
);
--RAISE NOTICE 'Record for event trigger %, objid: %,tag: %, current_user: %, database_owner: %, schemaname: %', r.object_identity, r.objid, tg_tag, current_user, databaseowner, r.schema_name;
IF r.object_identity = 'postgis_topology' THEN
EXECUTE format('DROP SCHEMA IF EXISTS topology');
END IF;
END LOOP;
END IF;
END;
$$;
ALTER FUNCTION _heroku.drop_ext() OWNER TO chris;
--
-- Name: extension_before_drop(); Type: FUNCTION; Schema: _heroku; Owner: chris
--
CREATE FUNCTION _heroku.extension_before_drop() RETURNS event_trigger
LANGUAGE plpgsql SECURITY DEFINER
AS $$
DECLARE
query TEXT;
BEGIN
query = (SELECT current_query());
-- RAISE NOTICE 'executing extension_before_drop: tg_event: %, tg_tag: %, current_user: %, session_user: %, query: %', tg_event, tg_tag, current_user, session_user, query;
IF tg_tag = 'DROP EXTENSION' and not pg_has_role(session_user, 'rds_superuser', 'MEMBER') THEN
-- DROP EXTENSION [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
IF (regexp_match(query, 'DROP\s+EXTENSION\s+(IF\s+EXISTS)?.*(plpgsql)', 'i') IS NOT NULL) THEN
RAISE EXCEPTION 'The plpgsql extension is required for database management and cannot be dropped.';
END IF;
END IF;
END;
$$;
ALTER FUNCTION _heroku.extension_before_drop() OWNER TO chris;
--
-- Name: grant_table_if_exists(text, text, text, text); Type: FUNCTION; Schema: _heroku; Owner: chris
--
CREATE FUNCTION _heroku.grant_table_if_exists(alias_schemaname text, grants text, databaseowner text, alias_tablename text DEFAULT NULL::text) RETURNS void
LANGUAGE plpgsql SECURITY DEFINER
AS $$
BEGIN
IF alias_tablename IS NULL THEN
EXECUTE format('GRANT %s ON ALL TABLES IN SCHEMA %I TO %I;', grants, alias_schemaname, databaseowner);
ELSE
IF EXISTS (SELECT 1 FROM pg_tables WHERE pg_tables.schemaname = alias_schemaname AND pg_tables.tablename = alias_tablename) THEN
EXECUTE format('GRANT %s ON TABLE %I.%I TO %I;', grants, alias_schemaname, alias_tablename, databaseowner);
END IF;
END IF;
END;
$$;
ALTER FUNCTION _heroku.grant_table_if_exists(alias_schemaname text, grants text, databaseowner text, alias_tablename text) OWNER TO chris;
--
-- Name: postgis_after_create(); Type: FUNCTION; Schema: _heroku; Owner: chris
--
CREATE FUNCTION _heroku.postgis_after_create() RETURNS void
LANGUAGE plpgsql SECURITY DEFINER
AS $$
DECLARE
schemaname TEXT;
databaseowner TEXT;
BEGIN
schemaname = (
SELECT n.nspname
FROM pg_catalog.pg_extension AS e
INNER JOIN pg_catalog.pg_namespace AS n ON e.extnamespace = n.oid
WHERE e.extname = 'postgis'
);
databaseowner = (
SELECT pg_catalog.pg_get_userbyid(d.datdba)
FROM pg_catalog.pg_database d
WHERE d.datname = current_database()
);
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.st_tileenvelope TO %I;', schemaname, databaseowner);
EXECUTE format('GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE %I.spatial_ref_sys TO %I;', schemaname, databaseowner);
END;
$$;
ALTER FUNCTION _heroku.postgis_after_create() OWNER TO chris;
--
-- Name: validate_extension(); Type: FUNCTION; Schema: _heroku; Owner: chris
--
CREATE FUNCTION _heroku.validate_extension() RETURNS event_trigger
LANGUAGE plpgsql SECURITY DEFINER
AS $$
DECLARE
schemaname TEXT;
r RECORD;
BEGIN
IF tg_tag = 'CREATE EXTENSION' and current_user != 'rds_superuser' THEN
FOR r IN SELECT * FROM pg_event_trigger_ddl_commands()
LOOP
CONTINUE WHEN r.command_tag != 'CREATE EXTENSION' OR r.object_type != 'extension';
schemaname = (
SELECT n.nspname
FROM pg_catalog.pg_extension AS e
INNER JOIN pg_catalog.pg_namespace AS n
ON e.extnamespace = n.oid
WHERE e.oid = r.objid
);
IF schemaname = '_heroku' THEN
RAISE EXCEPTION 'Creating extensions in the _heroku schema is not allowed';
END IF;
END LOOP;
END IF;
END;
$$;
ALTER FUNCTION _heroku.validate_extension() OWNER TO chris;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: blocked; Type: TABLE; Schema: public; Owner: chris
--
CREATE TABLE public.blocked (
user_id integer NOT NULL,
blocked_id integer NOT NULL
);
ALTER TABLE public.blocked OWNER TO chris;
--
-- Name: conversation_participants; Type: TABLE; Schema: public; Owner: chris
--
CREATE TABLE public.conversation_participants (
id integer NOT NULL,
conversation_id integer,
user_id integer,
added_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.conversation_participants OWNER TO chris;
--
-- Name: conversation_participants_id_seq; Type: SEQUENCE; Schema: public; Owner: chris
--
CREATE SEQUENCE public.conversation_participants_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.conversation_participants_id_seq OWNER TO chris;
--
-- Name: conversation_participants_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chris
--
ALTER SEQUENCE public.conversation_participants_id_seq OWNED BY public.conversation_participants.id;
--
-- Name: conversations; Type: TABLE; Schema: public; Owner: chris
--
CREATE TABLE public.conversations (
id integer NOT NULL,
name character varying(100),
is_group boolean DEFAULT false,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.conversations OWNER TO chris;
--
-- Name: conversations_id_seq; Type: SEQUENCE; Schema: public; Owner: chris
--
CREATE SEQUENCE public.conversations_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.conversations_id_seq OWNER TO chris;
--
-- Name: conversations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chris
--
ALTER SEQUENCE public.conversations_id_seq OWNED BY public.conversations.id;
--
-- Name: friend_requests; Type: TABLE; Schema: public; Owner: chris
--
CREATE TABLE public.friend_requests (
user_id integer NOT NULL,
request_id integer NOT NULL,
status character varying(10),
CONSTRAINT friend_requests_status_check CHECK (((status)::text = ANY ((ARRAY['pending'::character varying, 'accepted'::character varying, 'rejected'::character varying])::text[])))
);
ALTER TABLE public.friend_requests OWNER TO chris;
--
-- Name: friends; Type: TABLE; Schema: public; Owner: chris
--
CREATE TABLE public.friends (
user_id integer NOT NULL,
friend_id integer NOT NULL,
CONSTRAINT friends_check CHECK ((user_id < friend_id))
);
ALTER TABLE public.friends OWNER TO chris;
--
-- Name: messages; Type: TABLE; Schema: public; Owner: chris
--
CREATE TABLE public.messages (
id integer NOT NULL,
conversation_id integer,
sender_id integer,
content text NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
is_read boolean DEFAULT false
);
ALTER TABLE public.messages OWNER TO chris;
--
-- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: chris
--
CREATE SEQUENCE public.messages_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.messages_id_seq OWNER TO chris;
--
-- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chris
--
ALTER SEQUENCE public.messages_id_seq OWNED BY public.messages.id;
--
-- Name: sessions; Type: TABLE; Schema: public; Owner: chris
--
CREATE TABLE public.sessions (
session_id character varying(255) NOT NULL,
user_id integer,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
expires_at timestamp without time zone
);
ALTER TABLE public.sessions OWNER TO chris;
--
-- Name: users; Type: TABLE; Schema: public; Owner: chris
--
CREATE TABLE public.users (
id integer NOT NULL,
username character varying(50) NOT NULL,
password character varying(255) NOT NULL,
email character varying(100),
is_admin boolean DEFAULT false,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
is_public boolean DEFAULT true,
profile_picture character varying(500) DEFAULT NULL::character varying,
about_me character varying(500)
);
ALTER TABLE public.users OWNER TO chris;
--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: chris
--
CREATE SEQUENCE public.users_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.users_id_seq OWNER TO chris;
--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chris
--
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
--
-- Name: conversation_participants id; Type: DEFAULT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.conversation_participants ALTER COLUMN id SET DEFAULT nextval('public.conversation_participants_id_seq'::regclass);
--
-- Name: conversations id; Type: DEFAULT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.conversations ALTER COLUMN id SET DEFAULT nextval('public.conversations_id_seq'::regclass);
--
-- Name: messages id; Type: DEFAULT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.messages ALTER COLUMN id SET DEFAULT nextval('public.messages_id_seq'::regclass);
--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
--
-- Name: blocked blocked_pkey; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.blocked
ADD CONSTRAINT blocked_pkey PRIMARY KEY (user_id, blocked_id);
--
-- Name: conversation_participants conversation_participants_pkey; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.conversation_participants
ADD CONSTRAINT conversation_participants_pkey PRIMARY KEY (id);
--
-- Name: conversations conversations_pkey; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.conversations
ADD CONSTRAINT conversations_pkey PRIMARY KEY (id);
--
-- Name: friend_requests friend_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.friend_requests
ADD CONSTRAINT friend_requests_pkey PRIMARY KEY (user_id, request_id);
--
-- Name: friends friends_pkey; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.friends
ADD CONSTRAINT friends_pkey PRIMARY KEY (user_id, friend_id);
--
-- Name: messages messages_pkey; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.messages
ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
--
-- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.sessions
ADD CONSTRAINT sessions_pkey PRIMARY KEY (session_id);
--
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_email_key UNIQUE (email);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_username_key UNIQUE (username);
--
-- Name: blocked blocked_blocked_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.blocked
ADD CONSTRAINT blocked_blocked_id_fkey FOREIGN KEY (blocked_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: blocked blocked_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.blocked
ADD CONSTRAINT blocked_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: conversation_participants conversation_participants_conversation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.conversation_participants
ADD CONSTRAINT conversation_participants_conversation_id_fkey FOREIGN KEY (conversation_id) REFERENCES public.conversations(id) ON DELETE CASCADE;
--
-- Name: conversation_participants conversation_participants_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.conversation_participants
ADD CONSTRAINT conversation_participants_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: friend_requests friend_requests_request_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.friend_requests
ADD CONSTRAINT friend_requests_request_id_fkey FOREIGN KEY (request_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: friend_requests friend_requests_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.friend_requests
ADD CONSTRAINT friend_requests_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: friends friends_friend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.friends
ADD CONSTRAINT friends_friend_id_fkey FOREIGN KEY (friend_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: friends friends_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.friends
ADD CONSTRAINT friends_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: messages messages_conversation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.messages
ADD CONSTRAINT messages_conversation_id_fkey FOREIGN KEY (conversation_id) REFERENCES public.conversations(id) ON DELETE CASCADE;
--
-- Name: messages messages_sender_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.messages
ADD CONSTRAINT messages_sender_id_fkey FOREIGN KEY (sender_id) REFERENCES public.users(id) ON DELETE SET NULL;
--
-- Name: sessions sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: chris
--
ALTER TABLE ONLY public.sessions
ADD CONSTRAINT sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: pg_database_owner
--
REVOKE USAGE ON SCHEMA public FROM PUBLIC;
--
-- Name: extension_before_drop; Type: EVENT TRIGGER; Schema: -; Owner: chris
--
CREATE EVENT TRIGGER extension_before_drop ON ddl_command_start
EXECUTE FUNCTION _heroku.extension_before_drop();
ALTER EVENT TRIGGER extension_before_drop OWNER TO chris;
--
-- Name: log_create_ext; Type: EVENT TRIGGER; Schema: -; Owner: chris
--
CREATE EVENT TRIGGER log_create_ext ON ddl_command_end
EXECUTE FUNCTION _heroku.create_ext();
ALTER EVENT TRIGGER log_create_ext OWNER TO chris;
--
-- Name: log_drop_ext; Type: EVENT TRIGGER; Schema: -; Owner: chris
--
CREATE EVENT TRIGGER log_drop_ext ON sql_drop
EXECUTE FUNCTION _heroku.drop_ext();
ALTER EVENT TRIGGER log_drop_ext OWNER TO chris;
--
-- Name: validate_extension; Type: EVENT TRIGGER; Schema: -; Owner: chris
--
CREATE EVENT TRIGGER validate_extension ON ddl_command_end
EXECUTE FUNCTION _heroku.validate_extension();
ALTER EVENT TRIGGER validate_extension OWNER TO chris;
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,715 @@
-- Downloaded from: https://github.com/Clar17y/Football-Events/blob/9783f281e6e568f8c3fa7cbdfa8995229870e1a7/schema.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.8 (Debian 16.8-1.pgdg120+1)
-- Dumped by pg_dump version 17.4
-- Started on 2025-07-16 10:07:12
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;
--
-- TOC entry 6 (class 2615 OID 24591)
-- Name: grassroots; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA grassroots;
ALTER SCHEMA grassroots OWNER TO postgres;
--
-- TOC entry 853 (class 1247 OID 24604)
-- Name: event_kind; Type: TYPE; Schema: grassroots; Owner: postgres
--
CREATE TYPE grassroots.event_kind AS ENUM (
'goal',
'assist',
'key_pass',
'save',
'interception',
'tackle',
'foul',
'penalty',
'free_kick',
'ball_out',
'own_goal'
);
ALTER TYPE grassroots.event_kind OWNER TO postgres;
--
-- TOC entry 886 (class 1247 OID 25269)
-- Name: position_code; Type: TYPE; Schema: grassroots; Owner: postgres
--
CREATE TYPE grassroots.position_code AS ENUM (
'GK',
'CB',
'RCB',
'LCB',
'SW',
'RB',
'LB',
'RWB',
'LWB',
'CDM',
'RDM',
'LDM',
'CM',
'RCM',
'LCM',
'CAM',
'RAM',
'LAM',
'RM',
'LM',
'RW',
'LW',
'RF',
'LF',
'CF',
'ST',
'SS',
'AM',
'DM',
'WM',
'WB',
'FB',
'SUB',
'BENCH'
);
ALTER TYPE grassroots.position_code OWNER TO postgres;
--
-- TOC entry 880 (class 1247 OID 25247)
-- Name: user_role; Type: TYPE; Schema: grassroots; Owner: postgres
--
CREATE TYPE grassroots.user_role AS ENUM (
'ADMIN',
'USER'
);
ALTER TYPE grassroots.user_role OWNER TO postgres;
--
-- TOC entry 226 (class 1255 OID 25266)
-- Name: update_updated_at_column(); Type: FUNCTION; Schema: grassroots; Owner: postgres
--
CREATE FUNCTION grassroots.update_updated_at_column() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$;
ALTER FUNCTION grassroots.update_updated_at_column() OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 221 (class 1259 OID 24668)
-- Name: awards; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.awards (
award_id uuid DEFAULT gen_random_uuid() NOT NULL,
season_id uuid NOT NULL,
player_id uuid NOT NULL,
category text NOT NULL,
notes text,
created_at timestamp(6) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp(6) with time zone,
created_by_user_id uuid NOT NULL,
deleted_at timestamp(3) without time zone,
deleted_by_user_id uuid,
is_deleted boolean DEFAULT false NOT NULL
);
ALTER TABLE grassroots.awards OWNER TO postgres;
--
-- TOC entry 220 (class 1259 OID 24658)
-- Name: events; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.events (
id uuid DEFAULT gen_random_uuid() NOT NULL,
match_id uuid NOT NULL,
season_id uuid NOT NULL,
created_at timestamp(6) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
period_number integer,
clock_ms integer,
kind grassroots.event_kind NOT NULL,
team_id uuid,
player_id uuid,
notes text,
sentiment integer DEFAULT 0 NOT NULL,
updated_at timestamp(6) with time zone,
created_by_user_id uuid NOT NULL,
deleted_at timestamp(3) without time zone,
deleted_by_user_id uuid,
is_deleted boolean DEFAULT false NOT NULL
);
ALTER TABLE grassroots.events OWNER TO postgres;
--
-- TOC entry 222 (class 1259 OID 24691)
-- Name: lineup; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.lineup (
match_id uuid NOT NULL,
player_id uuid NOT NULL,
start_min double precision DEFAULT 0 NOT NULL,
end_min double precision,
created_at timestamp(6) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp(6) with time zone,
created_by_user_id uuid NOT NULL,
deleted_at timestamp(3) without time zone,
deleted_by_user_id uuid,
is_deleted boolean DEFAULT false NOT NULL,
"position" grassroots.position_code NOT NULL
);
ALTER TABLE grassroots.lineup OWNER TO postgres;
--
-- TOC entry 223 (class 1259 OID 24700)
-- Name: match_awards; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.match_awards (
match_award_id uuid DEFAULT gen_random_uuid() NOT NULL,
match_id uuid NOT NULL,
player_id uuid NOT NULL,
category text NOT NULL,
notes text,
created_at timestamp(6) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp(6) with time zone
);
ALTER TABLE grassroots.match_awards OWNER TO postgres;
--
-- TOC entry 219 (class 1259 OID 24645)
-- Name: matches; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.matches (
match_id uuid DEFAULT gen_random_uuid() NOT NULL,
season_id uuid NOT NULL,
kickoff_ts timestamp(6) with time zone NOT NULL,
competition text,
home_team_id uuid NOT NULL,
away_team_id uuid NOT NULL,
venue text,
duration_mins integer DEFAULT 50 NOT NULL,
period_format text DEFAULT 'quarter'::text NOT NULL,
our_score integer DEFAULT 0 NOT NULL,
opponent_score integer DEFAULT 0 NOT NULL,
notes text,
created_at timestamp(6) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp(6) with time zone,
created_by_user_id uuid NOT NULL,
deleted_at timestamp(3) without time zone,
deleted_by_user_id uuid,
is_deleted boolean DEFAULT false NOT NULL
);
ALTER TABLE grassroots.matches OWNER TO postgres;
--
-- TOC entry 218 (class 1259 OID 24636)
-- Name: players; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.players (
id uuid DEFAULT gen_random_uuid() NOT NULL,
full_name text NOT NULL,
squad_number integer,
dob date,
notes text,
current_team uuid,
created_at timestamp(6) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp(6) with time zone,
created_by_user_id uuid NOT NULL,
deleted_at timestamp(3) without time zone,
deleted_by_user_id uuid,
is_deleted boolean DEFAULT false NOT NULL,
preferred_pos grassroots.position_code
);
ALTER TABLE grassroots.players OWNER TO postgres;
--
-- TOC entry 224 (class 1259 OID 24727)
-- Name: seasons; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.seasons (
season_id uuid DEFAULT gen_random_uuid() NOT NULL,
label text NOT NULL,
start_date date NOT NULL,
end_date date NOT NULL,
is_current boolean DEFAULT false NOT NULL,
description text,
created_at timestamp(6) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp(6) with time zone,
created_by_user_id uuid NOT NULL,
deleted_at timestamp(3) without time zone,
deleted_by_user_id uuid,
is_deleted boolean DEFAULT false NOT NULL
);
ALTER TABLE grassroots.seasons OWNER TO postgres;
--
-- TOC entry 217 (class 1259 OID 24627)
-- Name: teams; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.teams (
id uuid DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
home_kit_primary character varying(7),
home_kit_secondary character varying(7),
away_kit_primary character varying(7),
away_kit_secondary character varying(7),
logo_url text,
created_at timestamp(6) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp(6) with time zone,
created_by_user_id uuid NOT NULL,
deleted_at timestamp(3) without time zone,
deleted_by_user_id uuid,
is_deleted boolean DEFAULT false NOT NULL
);
ALTER TABLE grassroots.teams OWNER TO postgres;
--
-- TOC entry 225 (class 1259 OID 25251)
-- Name: users; Type: TABLE; Schema: grassroots; Owner: postgres
--
CREATE TABLE grassroots.users (
id uuid DEFAULT gen_random_uuid() NOT NULL,
email text NOT NULL,
password_hash text NOT NULL,
first_name text,
last_name text,
role grassroots.user_role DEFAULT 'USER'::grassroots.user_role NOT NULL,
email_verified boolean DEFAULT false NOT NULL,
created_at timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp(3) without time zone NOT NULL,
is_deleted boolean DEFAULT false NOT NULL,
deleted_at timestamp(3) without time zone,
deleted_by_user_id uuid
);
ALTER TABLE grassroots.users OWNER TO postgres;
--
-- TOC entry 3293 (class 2606 OID 24676)
-- Name: awards awards_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.awards
ADD CONSTRAINT awards_pkey PRIMARY KEY (award_id);
--
-- TOC entry 3291 (class 2606 OID 24667)
-- Name: events events_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.events
ADD CONSTRAINT events_pkey PRIMARY KEY (id);
--
-- TOC entry 3295 (class 2606 OID 24699)
-- Name: lineup lineup_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.lineup
ADD CONSTRAINT lineup_pkey PRIMARY KEY (match_id, player_id, start_min);
--
-- TOC entry 3298 (class 2606 OID 24708)
-- Name: match_awards match_awards_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.match_awards
ADD CONSTRAINT match_awards_pkey PRIMARY KEY (match_award_id);
--
-- TOC entry 3289 (class 2606 OID 24657)
-- Name: matches matches_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.matches
ADD CONSTRAINT matches_pkey PRIMARY KEY (match_id);
--
-- TOC entry 3287 (class 2606 OID 24644)
-- Name: players players_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.players
ADD CONSTRAINT players_pkey PRIMARY KEY (id);
--
-- TOC entry 3301 (class 2606 OID 24736)
-- Name: seasons seasons_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.seasons
ADD CONSTRAINT seasons_pkey PRIMARY KEY (season_id);
--
-- TOC entry 3284 (class 2606 OID 24635)
-- Name: teams teams_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.teams
ADD CONSTRAINT teams_pkey PRIMARY KEY (id);
--
-- TOC entry 3303 (class 2606 OID 25345)
-- Name: users users_email_key; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.users
ADD CONSTRAINT users_email_key UNIQUE (email);
--
-- TOC entry 3305 (class 2606 OID 25263)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- TOC entry 3296 (class 1259 OID 24739)
-- Name: match_awards_match_id_category_key; Type: INDEX; Schema: grassroots; Owner: postgres
--
CREATE UNIQUE INDEX match_awards_match_id_category_key ON grassroots.match_awards USING btree (match_id, category);
--
-- TOC entry 3285 (class 1259 OID 24738)
-- Name: players_fullname_team_unique; Type: INDEX; Schema: grassroots; Owner: postgres
--
CREATE UNIQUE INDEX players_fullname_team_unique ON grassroots.players USING btree (full_name, current_team);
--
-- TOC entry 3299 (class 1259 OID 24740)
-- Name: seasons_label_key; Type: INDEX; Schema: grassroots; Owner: postgres
--
CREATE UNIQUE INDEX seasons_label_key ON grassroots.seasons USING btree (label);
--
-- TOC entry 3282 (class 1259 OID 24737)
-- Name: teams_name_key; Type: INDEX; Schema: grassroots; Owner: postgres
--
CREATE UNIQUE INDEX teams_name_key ON grassroots.teams USING btree (name);
--
-- TOC entry 3332 (class 2620 OID 25267)
-- Name: users update_users_updated_at; Type: TRIGGER; Schema: grassroots; Owner: postgres
--
CREATE TRIGGER update_users_updated_at BEFORE UPDATE ON grassroots.users FOR EACH ROW EXECUTE FUNCTION grassroots.update_updated_at_column();
--
-- TOC entry 3320 (class 2606 OID 25410)
-- Name: awards awards_created_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.awards
ADD CONSTRAINT awards_created_by_user_id_fkey FOREIGN KEY (created_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 3321 (class 2606 OID 25415)
-- Name: awards awards_deleted_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.awards
ADD CONSTRAINT awards_deleted_by_user_id_fkey FOREIGN KEY (deleted_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- TOC entry 3322 (class 2606 OID 24776)
-- Name: awards awards_player_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.awards
ADD CONSTRAINT awards_player_id_fkey FOREIGN KEY (player_id) REFERENCES grassroots.players(id) ON DELETE CASCADE;
--
-- TOC entry 3323 (class 2606 OID 24781)
-- Name: awards awards_season_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.awards
ADD CONSTRAINT awards_season_id_fkey FOREIGN KEY (season_id) REFERENCES grassroots.seasons(season_id) ON DELETE CASCADE;
--
-- TOC entry 3316 (class 2606 OID 25400)
-- Name: events events_created_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.events
ADD CONSTRAINT events_created_by_user_id_fkey FOREIGN KEY (created_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 3317 (class 2606 OID 25405)
-- Name: events events_deleted_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.events
ADD CONSTRAINT events_deleted_by_user_id_fkey FOREIGN KEY (deleted_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- TOC entry 3318 (class 2606 OID 24766)
-- Name: events events_match_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.events
ADD CONSTRAINT events_match_id_fkey FOREIGN KEY (match_id) REFERENCES grassroots.matches(match_id) ON DELETE CASCADE;
--
-- TOC entry 3319 (class 2606 OID 24771)
-- Name: events events_team_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.events
ADD CONSTRAINT events_team_id_fkey FOREIGN KEY (team_id) REFERENCES grassroots.teams(id);
--
-- TOC entry 3324 (class 2606 OID 25420)
-- Name: lineup lineup_created_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.lineup
ADD CONSTRAINT lineup_created_by_user_id_fkey FOREIGN KEY (created_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 3325 (class 2606 OID 25425)
-- Name: lineup lineup_deleted_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.lineup
ADD CONSTRAINT lineup_deleted_by_user_id_fkey FOREIGN KEY (deleted_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- TOC entry 3326 (class 2606 OID 24786)
-- Name: lineup lineup_match_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.lineup
ADD CONSTRAINT lineup_match_id_fkey FOREIGN KEY (match_id) REFERENCES grassroots.matches(match_id) ON DELETE CASCADE;
--
-- TOC entry 3327 (class 2606 OID 24791)
-- Name: lineup lineup_player_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.lineup
ADD CONSTRAINT lineup_player_id_fkey FOREIGN KEY (player_id) REFERENCES grassroots.players(id) ON DELETE CASCADE;
--
-- TOC entry 3328 (class 2606 OID 24801)
-- Name: match_awards match_awards_match_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.match_awards
ADD CONSTRAINT match_awards_match_id_fkey FOREIGN KEY (match_id) REFERENCES grassroots.matches(match_id) ON DELETE CASCADE;
--
-- TOC entry 3329 (class 2606 OID 24806)
-- Name: match_awards match_awards_player_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.match_awards
ADD CONSTRAINT match_awards_player_id_fkey FOREIGN KEY (player_id) REFERENCES grassroots.players(id) ON DELETE CASCADE;
--
-- TOC entry 3311 (class 2606 OID 24751)
-- Name: matches matches_away_team_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.matches
ADD CONSTRAINT matches_away_team_id_fkey FOREIGN KEY (away_team_id) REFERENCES grassroots.teams(id) ON DELETE CASCADE;
--
-- TOC entry 3312 (class 2606 OID 25390)
-- Name: matches matches_created_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.matches
ADD CONSTRAINT matches_created_by_user_id_fkey FOREIGN KEY (created_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 3313 (class 2606 OID 25395)
-- Name: matches matches_deleted_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.matches
ADD CONSTRAINT matches_deleted_by_user_id_fkey FOREIGN KEY (deleted_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- TOC entry 3314 (class 2606 OID 24756)
-- Name: matches matches_home_team_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.matches
ADD CONSTRAINT matches_home_team_id_fkey FOREIGN KEY (home_team_id) REFERENCES grassroots.teams(id) ON DELETE CASCADE;
--
-- TOC entry 3315 (class 2606 OID 24761)
-- Name: matches matches_season_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.matches
ADD CONSTRAINT matches_season_id_fkey FOREIGN KEY (season_id) REFERENCES grassroots.seasons(season_id) ON DELETE CASCADE;
--
-- TOC entry 3308 (class 2606 OID 25380)
-- Name: players players_created_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.players
ADD CONSTRAINT players_created_by_user_id_fkey FOREIGN KEY (created_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 3309 (class 2606 OID 24741)
-- Name: players players_current_team_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.players
ADD CONSTRAINT players_current_team_fkey FOREIGN KEY (current_team) REFERENCES grassroots.teams(id);
--
-- TOC entry 3310 (class 2606 OID 25385)
-- Name: players players_deleted_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.players
ADD CONSTRAINT players_deleted_by_user_id_fkey FOREIGN KEY (deleted_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- TOC entry 3330 (class 2606 OID 25435)
-- Name: seasons seasons_created_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.seasons
ADD CONSTRAINT seasons_created_by_user_id_fkey FOREIGN KEY (created_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 3331 (class 2606 OID 25440)
-- Name: seasons seasons_deleted_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.seasons
ADD CONSTRAINT seasons_deleted_by_user_id_fkey FOREIGN KEY (deleted_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- TOC entry 3306 (class 2606 OID 25370)
-- Name: teams teams_created_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.teams
ADD CONSTRAINT teams_created_by_user_id_fkey FOREIGN KEY (created_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 3307 (class 2606 OID 25375)
-- Name: teams teams_deleted_by_user_id_fkey; Type: FK CONSTRAINT; Schema: grassroots; Owner: postgres
--
ALTER TABLE ONLY grassroots.teams
ADD CONSTRAINT teams_deleted_by_user_id_fkey FOREIGN KEY (deleted_by_user_id) REFERENCES grassroots.users(id) ON UPDATE CASCADE ON DELETE SET NULL;
-- Completed on 2025-07-16 10:07:12
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+949
View File
@@ -0,0 +1,949 @@
-- Downloaded from: https://github.com/DRON12261/EduVault/blob/d95f919c69452719e016c3afc53eb24280c11453/backup.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 17.4
-- Dumped by pg_dump version 17.4
-- Started on 2025-05-04 21:20:55
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;
--
-- TOC entry 4 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: pg_database_owner
--
CREATE SCHEMA IF NOT EXISTS public;
ALTER SCHEMA public OWNER TO pg_database_owner;
--
-- TOC entry 4900 (class 0 OID 0)
-- Dependencies: 4
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: pg_database_owner
--
COMMENT ON SCHEMA public IS 'standard public schema';
--
-- TOC entry 237 (class 1255 OID 16628)
-- Name: Login(character varying, character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public."Login"(login_to_check character varying, password_to_check character varying) RETURNS boolean
LANGUAGE plpgsql
AS $$DECLARE
permission boolean;
BEGIN
SELECT
EXISTS
(
SELECT * FROM "Users"
WHERE "Users".login = login_to_check
AND "Users".password = password_to_check
)
INTO permission;
RETURN permission;
END;$$;
ALTER FUNCTION public."Login"(login_to_check character varying, password_to_check character varying) OWNER TO postgres;
--
-- TOC entry 238 (class 1255 OID 16636)
-- Name: test_func(character varying, character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.test_func(character varying, character varying) RETURNS integer
LANGUAGE plpgsql
AS $$DECLARE
kek integer;
BEGIN
SELECT user_id from "Users" into kek;
RETURN kek;
END;$$;
ALTER FUNCTION public.test_func(character varying, character varying) OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 224 (class 1259 OID 16459)
-- Name: AccessRights; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."AccessRights" (
accessright_id bigint NOT NULL,
user_id bigint,
role_id bigint,
accessrighttype_id bigint NOT NULL,
record_id bigint NOT NULL
);
ALTER TABLE public."AccessRights" OWNER TO postgres;
--
-- TOC entry 230 (class 1259 OID 16509)
-- Name: AccessRightsTypes; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."AccessRightsTypes" (
accessrighttype_id bigint NOT NULL,
artname character varying NOT NULL
);
ALTER TABLE public."AccessRightsTypes" OWNER TO postgres;
--
-- TOC entry 229 (class 1259 OID 16508)
-- Name: AccessRightsTypes_art_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."AccessRightsTypes_art_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."AccessRightsTypes_art_id_seq" OWNER TO postgres;
--
-- TOC entry 4901 (class 0 OID 0)
-- Dependencies: 229
-- Name: AccessRightsTypes_art_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."AccessRightsTypes_art_id_seq" OWNED BY public."AccessRightsTypes".accessrighttype_id;
--
-- TOC entry 223 (class 1259 OID 16458)
-- Name: AccessRights_accessright_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."AccessRights_accessright_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."AccessRights_accessright_id_seq" OWNER TO postgres;
--
-- TOC entry 4902 (class 0 OID 0)
-- Dependencies: 223
-- Name: AccessRights_accessright_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."AccessRights_accessright_id_seq" OWNED BY public."AccessRights".accessright_id;
--
-- TOC entry 228 (class 1259 OID 16475)
-- Name: Fields; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."Fields" (
field_id bigint NOT NULL,
name character varying NOT NULL,
record_id bigint NOT NULL,
value character varying,
filetypefield_id bigint
);
ALTER TABLE public."Fields" OWNER TO postgres;
--
-- TOC entry 226 (class 1259 OID 16466)
-- Name: FileTypes; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."FileTypes" (
filetype_id bigint NOT NULL,
typename character varying NOT NULL
);
ALTER TABLE public."FileTypes" OWNER TO postgres;
--
-- TOC entry 234 (class 1259 OID 16540)
-- Name: FileTypesFields; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."FileTypesFields" (
filetypefield_id bigint NOT NULL,
filetype_id bigint NOT NULL,
name character varying NOT NULL,
isrequired boolean NOT NULL,
prefilling boolean NOT NULL
);
ALTER TABLE public."FileTypesFields" OWNER TO postgres;
--
-- TOC entry 233 (class 1259 OID 16539)
-- Name: FileTypesFields_filetypefield_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."FileTypesFields_filetypefield_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."FileTypesFields_filetypefield_id_seq" OWNER TO postgres;
--
-- TOC entry 4903 (class 0 OID 0)
-- Dependencies: 233
-- Name: FileTypesFields_filetypefield_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."FileTypesFields_filetypefield_id_seq" OWNED BY public."FileTypesFields".filetypefield_id;
--
-- TOC entry 225 (class 1259 OID 16465)
-- Name: FileTypes_filetype_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."FileTypes_filetype_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."FileTypes_filetype_id_seq" OWNER TO postgres;
--
-- TOC entry 4904 (class 0 OID 0)
-- Dependencies: 225
-- Name: FileTypes_filetype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."FileTypes_filetype_id_seq" OWNED BY public."FileTypes".filetype_id;
--
-- TOC entry 218 (class 1259 OID 16431)
-- Name: Records; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."Records" (
record_id bigint NOT NULL,
filetype_id bigint NOT NULL,
name character varying,
filepath character varying,
author character varying NOT NULL
);
ALTER TABLE public."Records" OWNER TO postgres;
--
-- TOC entry 217 (class 1259 OID 16430)
-- Name: Metadata_metadata_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."Metadata_metadata_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."Metadata_metadata_id_seq" OWNER TO postgres;
--
-- TOC entry 4905 (class 0 OID 0)
-- Dependencies: 217
-- Name: Metadata_metadata_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."Metadata_metadata_id_seq" OWNED BY public."Records".record_id;
--
-- TOC entry 232 (class 1259 OID 16523)
-- Name: RecordsRelations; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."RecordsRelations" (
relation_id bigint NOT NULL,
sourcerecord bigint NOT NULL,
targetrecord bigint NOT NULL
);
ALTER TABLE public."RecordsRelations" OWNER TO postgres;
--
-- TOC entry 231 (class 1259 OID 16522)
-- Name: RecordsRelations_relation_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."RecordsRelations_relation_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."RecordsRelations_relation_id_seq" OWNER TO postgres;
--
-- TOC entry 4906 (class 0 OID 0)
-- Dependencies: 231
-- Name: RecordsRelations_relation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."RecordsRelations_relation_id_seq" OWNED BY public."RecordsRelations".relation_id;
--
-- TOC entry 222 (class 1259 OID 16449)
-- Name: Roles; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."Roles" (
role_id bigint NOT NULL,
rolename character varying NOT NULL
);
ALTER TABLE public."Roles" OWNER TO postgres;
--
-- TOC entry 221 (class 1259 OID 16448)
-- Name: Roles_role_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."Roles_role_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."Roles_role_id_seq" OWNER TO postgres;
--
-- TOC entry 4907 (class 0 OID 0)
-- Dependencies: 221
-- Name: Roles_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."Roles_role_id_seq" OWNED BY public."Roles".role_id;
--
-- TOC entry 227 (class 1259 OID 16474)
-- Name: UserMetadata_usermetadata_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."UserMetadata_usermetadata_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."UserMetadata_usermetadata_id_seq" OWNER TO postgres;
--
-- TOC entry 4908 (class 0 OID 0)
-- Dependencies: 227
-- Name: UserMetadata_usermetadata_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."UserMetadata_usermetadata_id_seq" OWNED BY public."Fields".field_id;
--
-- TOC entry 220 (class 1259 OID 16440)
-- Name: Users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."Users" (
user_id bigint NOT NULL,
login character varying NOT NULL,
password character varying NOT NULL,
name character varying,
usertype bigint
);
ALTER TABLE public."Users" OWNER TO postgres;
--
-- TOC entry 235 (class 1259 OID 16571)
-- Name: UsersRoles; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."UsersRoles" (
usersroles_id bigint NOT NULL,
user_id bigint NOT NULL,
role_id bigint NOT NULL
);
ALTER TABLE public."UsersRoles" OWNER TO postgres;
--
-- TOC entry 236 (class 1259 OID 16574)
-- Name: UsersRoles_usersroles_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."UsersRoles_usersroles_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."UsersRoles_usersroles_id_seq" OWNER TO postgres;
--
-- TOC entry 4909 (class 0 OID 0)
-- Dependencies: 236
-- Name: UsersRoles_usersroles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."UsersRoles_usersroles_id_seq" OWNED BY public."UsersRoles".usersroles_id;
--
-- TOC entry 219 (class 1259 OID 16439)
-- Name: Users_user_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public."Users_user_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public."Users_user_id_seq" OWNER TO postgres;
--
-- TOC entry 4910 (class 0 OID 0)
-- Dependencies: 219
-- Name: Users_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public."Users_user_id_seq" OWNED BY public."Users".user_id;
--
-- TOC entry 4691 (class 2604 OID 16562)
-- Name: AccessRights accessright_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."AccessRights" ALTER COLUMN accessright_id SET DEFAULT nextval('public."AccessRights_accessright_id_seq"'::regclass);
--
-- TOC entry 4694 (class 2604 OID 16563)
-- Name: AccessRightsTypes accessrighttype_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."AccessRightsTypes" ALTER COLUMN accessrighttype_id SET DEFAULT nextval('public."AccessRightsTypes_art_id_seq"'::regclass);
--
-- TOC entry 4693 (class 2604 OID 16569)
-- Name: Fields field_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Fields" ALTER COLUMN field_id SET DEFAULT nextval('public."UserMetadata_usermetadata_id_seq"'::regclass);
--
-- TOC entry 4692 (class 2604 OID 16564)
-- Name: FileTypes filetype_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."FileTypes" ALTER COLUMN filetype_id SET DEFAULT nextval('public."FileTypes_filetype_id_seq"'::regclass);
--
-- TOC entry 4696 (class 2604 OID 16565)
-- Name: FileTypesFields filetypefield_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."FileTypesFields" ALTER COLUMN filetypefield_id SET DEFAULT nextval('public."FileTypesFields_filetypefield_id_seq"'::regclass);
--
-- TOC entry 4688 (class 2604 OID 16566)
-- Name: Records record_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Records" ALTER COLUMN record_id SET DEFAULT nextval('public."Metadata_metadata_id_seq"'::regclass);
--
-- TOC entry 4695 (class 2604 OID 16567)
-- Name: RecordsRelations relation_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."RecordsRelations" ALTER COLUMN relation_id SET DEFAULT nextval('public."RecordsRelations_relation_id_seq"'::regclass);
--
-- TOC entry 4690 (class 2604 OID 16568)
-- Name: Roles role_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Roles" ALTER COLUMN role_id SET DEFAULT nextval('public."Roles_role_id_seq"'::regclass);
--
-- TOC entry 4689 (class 2604 OID 16570)
-- Name: Users user_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Users" ALTER COLUMN user_id SET DEFAULT nextval('public."Users_user_id_seq"'::regclass);
--
-- TOC entry 4697 (class 2604 OID 16575)
-- Name: UsersRoles usersroles_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."UsersRoles" ALTER COLUMN usersroles_id SET DEFAULT nextval('public."UsersRoles_usersroles_id_seq"'::regclass);
--
-- TOC entry 4882 (class 0 OID 16459)
-- Dependencies: 224
-- Data for Name: AccessRights; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."AccessRights" (accessright_id, user_id, role_id, accessrighttype_id, record_id) FROM stdin;
\.
--
-- TOC entry 4888 (class 0 OID 16509)
-- Dependencies: 230
-- Data for Name: AccessRightsTypes; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."AccessRightsTypes" (accessrighttype_id, artname) FROM stdin;
\.
--
-- TOC entry 4886 (class 0 OID 16475)
-- Dependencies: 228
-- Data for Name: Fields; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."Fields" (field_id, name, record_id, value, filetypefield_id) FROM stdin;
\.
--
-- TOC entry 4884 (class 0 OID 16466)
-- Dependencies: 226
-- Data for Name: FileTypes; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."FileTypes" (filetype_id, typename) FROM stdin;
\.
--
-- TOC entry 4892 (class 0 OID 16540)
-- Dependencies: 234
-- Data for Name: FileTypesFields; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."FileTypesFields" (filetypefield_id, filetype_id, name, isrequired, prefilling) FROM stdin;
\.
--
-- TOC entry 4876 (class 0 OID 16431)
-- Dependencies: 218
-- Data for Name: Records; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."Records" (record_id, filetype_id, name, filepath, author) FROM stdin;
\.
--
-- TOC entry 4890 (class 0 OID 16523)
-- Dependencies: 232
-- Data for Name: RecordsRelations; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."RecordsRelations" (relation_id, sourcerecord, targetrecord) FROM stdin;
\.
--
-- TOC entry 4880 (class 0 OID 16449)
-- Dependencies: 222
-- Data for Name: Roles; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."Roles" (role_id, rolename) FROM stdin;
\.
--
-- TOC entry 4878 (class 0 OID 16440)
-- Dependencies: 220
-- Data for Name: Users; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."Users" (user_id, login, password, name, usertype) FROM stdin;
1 test test TestUser 1
\.
--
-- TOC entry 4893 (class 0 OID 16571)
-- Dependencies: 235
-- Data for Name: UsersRoles; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."UsersRoles" (usersroles_id, user_id, role_id) FROM stdin;
\.
--
-- TOC entry 4911 (class 0 OID 0)
-- Dependencies: 229
-- Name: AccessRightsTypes_art_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."AccessRightsTypes_art_id_seq"', 1, false);
--
-- TOC entry 4912 (class 0 OID 0)
-- Dependencies: 223
-- Name: AccessRights_accessright_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."AccessRights_accessright_id_seq"', 1, false);
--
-- TOC entry 4913 (class 0 OID 0)
-- Dependencies: 233
-- Name: FileTypesFields_filetypefield_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."FileTypesFields_filetypefield_id_seq"', 1, false);
--
-- TOC entry 4914 (class 0 OID 0)
-- Dependencies: 225
-- Name: FileTypes_filetype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."FileTypes_filetype_id_seq"', 1, false);
--
-- TOC entry 4915 (class 0 OID 0)
-- Dependencies: 217
-- Name: Metadata_metadata_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."Metadata_metadata_id_seq"', 1, false);
--
-- TOC entry 4916 (class 0 OID 0)
-- Dependencies: 231
-- Name: RecordsRelations_relation_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."RecordsRelations_relation_id_seq"', 1, false);
--
-- TOC entry 4917 (class 0 OID 0)
-- Dependencies: 221
-- Name: Roles_role_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."Roles_role_id_seq"', 1, false);
--
-- TOC entry 4918 (class 0 OID 0)
-- Dependencies: 227
-- Name: UserMetadata_usermetadata_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."UserMetadata_usermetadata_id_seq"', 1, false);
--
-- TOC entry 4919 (class 0 OID 0)
-- Dependencies: 236
-- Name: UsersRoles_usersroles_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."UsersRoles_usersroles_id_seq"', 1, false);
--
-- TOC entry 4920 (class 0 OID 0)
-- Dependencies: 219
-- Name: Users_user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."Users_user_id_seq"', 1, true);
--
-- TOC entry 4711 (class 2606 OID 16516)
-- Name: AccessRightsTypes AccessRightsTypes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."AccessRightsTypes"
ADD CONSTRAINT "AccessRightsTypes_pkey" PRIMARY KEY (accessrighttype_id);
--
-- TOC entry 4705 (class 2606 OID 16464)
-- Name: AccessRights AccessRights_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."AccessRights"
ADD CONSTRAINT "AccessRights_pkey" PRIMARY KEY (accessright_id);
--
-- TOC entry 4715 (class 2606 OID 16547)
-- Name: FileTypesFields FileTypesFields_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."FileTypesFields"
ADD CONSTRAINT "FileTypesFields_pkey" PRIMARY KEY (filetypefield_id);
--
-- TOC entry 4707 (class 2606 OID 16473)
-- Name: FileTypes FileTypes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."FileTypes"
ADD CONSTRAINT "FileTypes_pkey" PRIMARY KEY (filetype_id);
--
-- TOC entry 4699 (class 2606 OID 16438)
-- Name: Records Metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Records"
ADD CONSTRAINT "Metadata_pkey" PRIMARY KEY (record_id);
--
-- TOC entry 4713 (class 2606 OID 16528)
-- Name: RecordsRelations RecordsRelations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."RecordsRelations"
ADD CONSTRAINT "RecordsRelations_pkey" PRIMARY KEY (relation_id);
--
-- TOC entry 4703 (class 2606 OID 16456)
-- Name: Roles Roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Roles"
ADD CONSTRAINT "Roles_pkey" PRIMARY KEY (role_id);
--
-- TOC entry 4709 (class 2606 OID 16482)
-- Name: Fields UserMetadata_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Fields"
ADD CONSTRAINT "UserMetadata_pkey" PRIMARY KEY (field_id);
--
-- TOC entry 4717 (class 2606 OID 16580)
-- Name: UsersRoles UsersRoles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."UsersRoles"
ADD CONSTRAINT "UsersRoles_pkey" PRIMARY KEY (usersroles_id);
--
-- TOC entry 4701 (class 2606 OID 16447)
-- Name: Users Users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Users"
ADD CONSTRAINT "Users_pkey" PRIMARY KEY (user_id);
--
-- TOC entry 4719 (class 2606 OID 16517)
-- Name: AccessRights accessrights_ART; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."AccessRights"
ADD CONSTRAINT "accessrights_ART" FOREIGN KEY (accessrighttype_id) REFERENCES public."AccessRightsTypes"(accessrighttype_id) NOT VALID;
--
-- TOC entry 4720 (class 2606 OID 16498)
-- Name: AccessRights accessrights_records; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."AccessRights"
ADD CONSTRAINT accessrights_records FOREIGN KEY (record_id) REFERENCES public."Records"(record_id) NOT VALID;
--
-- TOC entry 4721 (class 2606 OID 16493)
-- Name: AccessRights accessrights_roles; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."AccessRights"
ADD CONSTRAINT accessrights_roles FOREIGN KEY (role_id) REFERENCES public."Roles"(role_id) NOT VALID;
--
-- TOC entry 4722 (class 2606 OID 16488)
-- Name: AccessRights accessrights_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."AccessRights"
ADD CONSTRAINT accessrights_users FOREIGN KEY (user_id) REFERENCES public."Users"(user_id) NOT VALID;
--
-- TOC entry 4723 (class 2606 OID 16591)
-- Name: Fields files_filetypesfields; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Fields"
ADD CONSTRAINT files_filetypesfields FOREIGN KEY (filetypefield_id) REFERENCES public."FileTypesFields"(filetypefield_id) NOT VALID;
--
-- TOC entry 4724 (class 2606 OID 16503)
-- Name: Fields files_records; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Fields"
ADD CONSTRAINT files_records FOREIGN KEY (record_id) REFERENCES public."Records"(record_id) NOT VALID;
--
-- TOC entry 4727 (class 2606 OID 16548)
-- Name: FileTypesFields filetypesfields_filetypes; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."FileTypesFields"
ADD CONSTRAINT filetypesfields_filetypes FOREIGN KEY (filetype_id) REFERENCES public."FileTypes"(filetype_id);
--
-- TOC entry 4718 (class 2606 OID 16483)
-- Name: Records metadata_filetypes; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."Records"
ADD CONSTRAINT metadata_filetypes FOREIGN KEY (filetype_id) REFERENCES public."FileTypes"(filetype_id) NOT VALID;
--
-- TOC entry 4725 (class 2606 OID 16529)
-- Name: RecordsRelations sourcerecord_records; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."RecordsRelations"
ADD CONSTRAINT sourcerecord_records FOREIGN KEY (sourcerecord) REFERENCES public."Records"(record_id);
--
-- TOC entry 4726 (class 2606 OID 16534)
-- Name: RecordsRelations targetrecord_records; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."RecordsRelations"
ADD CONSTRAINT targetrecord_records FOREIGN KEY (targetrecord) REFERENCES public."Records"(record_id);
--
-- TOC entry 4728 (class 2606 OID 16586)
-- Name: UsersRoles usersroles_roles; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."UsersRoles"
ADD CONSTRAINT usersroles_roles FOREIGN KEY (role_id) REFERENCES public."Roles"(role_id) NOT VALID;
--
-- TOC entry 4729 (class 2606 OID 16581)
-- Name: UsersRoles usersroles_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."UsersRoles"
ADD CONSTRAINT usersroles_users FOREIGN KEY (user_id) REFERENCES public."Users"(user_id) NOT VALID;
-- Completed on 2025-05-04 21:20:56
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,606 @@
-- Downloaded from: https://github.com/DmitryAntipin151002/Diplom/blob/350c6c1b05e8ce85abe2eca8a77acacf5b14e4d4/dump_AuthS.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 17.4
-- Dumped by pg_dump version 17.4
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;
--
-- Name: update_activity_stats(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.update_activity_stats() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE user_profiles
SET
total_activities = (SELECT COUNT(*) FROM user_activities WHERE user_id = NEW.user_id),
total_distance = (SELECT COALESCE(SUM(distance), 0) FROM user_activities WHERE user_id = NEW.user_id),
updated_at = CURRENT_TIMESTAMP
WHERE user_id = NEW.user_id;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.update_activity_stats() OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: event; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.event (
id integer NOT NULL,
name character varying(255),
description text,
event_date timestamp without time zone,
max_participants integer,
organizer_id uuid
);
ALTER TABLE public.event OWNER TO postgres;
--
-- Name: event_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.event_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.event_id_seq OWNER TO postgres;
--
-- Name: event_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.event_id_seq OWNED BY public.event.id;
--
-- Name: event_participant; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.event_participant (
id integer NOT NULL,
user_id uuid,
joined_at timestamp without time zone,
event_id integer
);
ALTER TABLE public.event_participant OWNER TO postgres;
--
-- Name: event_participant_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.event_participant_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.event_participant_id_seq OWNER TO postgres;
--
-- Name: event_participant_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.event_participant_id_seq OWNED BY public.event_participant.id;
--
-- Name: role; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.role (
id integer NOT NULL,
name character varying(50) NOT NULL
);
ALTER TABLE public.role OWNER TO postgres;
--
-- Name: role_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.role_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.role_id_seq OWNER TO postgres;
--
-- Name: role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.role_id_seq OWNED BY public.role.id;
--
-- Name: status; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.status (
id integer NOT NULL,
name character varying(50) NOT NULL
);
ALTER TABLE public.status OWNER TO postgres;
--
-- Name: status_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.status_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.status_id_seq OWNER TO postgres;
--
-- Name: status_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.status_id_seq OWNED BY public.status.id;
--
-- Name: user_activities; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.user_activities (
id uuid DEFAULT gen_random_uuid() NOT NULL,
user_id uuid,
activity_type character varying(50) NOT NULL,
distance numeric(10,2),
duration text,
calories_burned integer,
activity_date timestamp without time zone NOT NULL,
external_id character varying(100),
raw_data character varying
);
ALTER TABLE public.user_activities OWNER TO postgres;
--
-- Name: user_photos; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.user_photos (
id uuid DEFAULT gen_random_uuid() NOT NULL,
user_id uuid,
photo_url character varying(255) NOT NULL,
is_main boolean DEFAULT false,
uploaded_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
description text
);
ALTER TABLE public.user_photos OWNER TO postgres;
--
-- Name: user_profiles; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.user_profiles (
user_id uuid NOT NULL,
avatar_url character varying(255),
bio text,
date_of_birth date,
gender character varying(10),
location character varying(100),
sport_type character varying(50),
fitness_level character varying(20),
goals text,
achievements text,
total_activities integer DEFAULT 0,
total_distance numeric(10,2) DEFAULT 0,
total_wins integer DEFAULT 0,
personal_records text,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
is_verified boolean,
last_active_at date,
CONSTRAINT user_profiles_fitness_level_check CHECK (((fitness_level)::text = ANY (ARRAY[('Beginner'::character varying)::text, ('Intermediate'::character varying)::text, ('Advanced'::character varying)::text]))),
CONSTRAINT user_profiles_gender_check CHECK (((gender)::text = ANY (ARRAY[('Male'::character varying)::text, ('Female'::character varying)::text, ('Other'::character varying)::text])))
);
ALTER TABLE public.user_profiles OWNER TO postgres;
--
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.users (
id uuid DEFAULT gen_random_uuid() NOT NULL,
email character varying(100) NOT NULL,
phone_number character varying(15),
encrypted_password character(60) NOT NULL,
status bigint,
is_first_enter boolean DEFAULT false NOT NULL,
end_date date,
role_id bigint NOT NULL,
last_login date
);
ALTER TABLE public.users OWNER TO postgres;
--
-- Name: verification_code; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.verification_code (
id uuid NOT NULL,
user_id uuid NOT NULL,
code character varying(6) NOT NULL,
created_at timestamp without time zone NOT NULL,
expires_at timestamp without time zone NOT NULL
);
ALTER TABLE public.verification_code OWNER TO postgres;
--
-- Name: event id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.event ALTER COLUMN id SET DEFAULT nextval('public.event_id_seq'::regclass);
--
-- Name: event_participant id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.event_participant ALTER COLUMN id SET DEFAULT nextval('public.event_participant_id_seq'::regclass);
--
-- Name: role id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.role ALTER COLUMN id SET DEFAULT nextval('public.role_id_seq'::regclass);
--
-- Name: status id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.status ALTER COLUMN id SET DEFAULT nextval('public.status_id_seq'::regclass);
--
-- Data for Name: event; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.event (id, name, description, event_date, max_participants, organizer_id) FROM stdin;
2 Футбол на стадионе Дружеский матч на 10 человек 2025-04-09 17:00:00 10 6b1cf72a-60b3-4f78-ac20-cfc2e75b8512
\.
--
-- Data for Name: event_participant; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.event_participant (id, user_id, joined_at, event_id) FROM stdin;
\.
--
-- Data for Name: role; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.role (id, name) FROM stdin;
1 ADMIN
2 USER
\.
--
-- Data for Name: status; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.status (id, name) FROM stdin;
1 ACTIVE
\.
--
-- Data for Name: user_activities; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.user_activities (id, user_id, activity_type, distance, duration, calories_burned, activity_date, external_id, raw_data) FROM stdin;
dfa160ae-d33f-4b01-8672-8168bd744ca3 960b0c25-4568-4a4a-b45a-1edf4a6dfcfc Running 5.00 PT30M 500 2025-04-05 20:03:26.558959 external-id-123 {"speed": "12km/h"}
\.
--
-- Data for Name: user_photos; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.user_photos (id, user_id, photo_url, is_main, uploaded_at, description) FROM stdin;
d5023ad9-591d-4a9f-9872-bf3209bc7166 960b0c25-4568-4a4a-b45a-1edf4a6dfcfc http://example.com/new-avatar.jpg t 2025-04-05 19:50:16.791349 \N
\.
--
-- Data for Name: user_profiles; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.user_profiles (user_id, avatar_url, bio, date_of_birth, gender, location, sport_type, fitness_level, goals, achievements, total_activities, total_distance, total_wins, personal_records, created_at, updated_at, is_verified, last_active_at) FROM stdin;
960b0c25-4568-4a4a-b45a-1edf4a6dfcfc http://example.com/avatar.jpg Bio of the user 1990-01-01 Male New Sity Outdoor Intermediate Run 5k Completed 10k 1 5.00 5 5k in 30min 2025-04-05 16:09:11.481505 2025-04-05 20:03:26.561609 t 2025-04-05
6b1cf72a-60b3-4f78-ac20-cfc2e75b8512 http://example.com/avatar.jpg Bio of the user 1990-01-01 Male New York Outdoor Intermediate Run 5k Completed 10k 10 100.50 5 5k in 30min 2025-04-08 13:00:54.036292 2025-04-08 13:00:54.036292 t 2025-04-05
\.
--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.users (id, email, phone_number, encrypted_password, status, is_first_enter, end_date, role_id, last_login) FROM stdin;
ce2082c5-1f56-4293-aac4-4a057c6980bc user@example.com +1234567890 $2a$10$.PC11OLxxrEH8IodYZGY2OX4T617k4qq6vbrlGN4MdQNtnJGcI5j6 1 t \N 1 \N
960b0c25-4568-4a4a-b45a-1edf4a6dfcfc user@example1.com \N $2a$10$xYVXvwWtPQD/gqgANOVxeuMkAHK83PTcv5tm3QTM51JpAXHXP/Ake 1 f \N 1 2025-04-05
73c398a7-6612-4764-97ec-098c5802ae97 user@example2.com \N $2a$10$8AP//1k2Son9d/JUdUU6VuwMHGK9pzoCEAMhD5ryVN2MiMP56Pv7y 1 t \N 1 2025-04-05
1a54beaa-6290-4dbf-b18b-a3df94cc63b5 user@example4.com \N $2a$10$7E6Pt9/01D8jKK4z0i98BesuxJVVSxLbIO1VWEVkiT1jc2yH.LLAG 1 t \N 1 2025-04-05
6b1cf72a-60b3-4f78-ac20-cfc2e75b8512 dmitry@example.com \N $2a$10$hEZdn2vPjZkCJdMDuMs.hO31SyLqbIFgCeYfFcexZFVRBQIZeJzeq 1 t \N 1 2025-04-08
\.
--
-- Data for Name: verification_code; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.verification_code (id, user_id, code, created_at, expires_at) FROM stdin;
3b9a4c0b-b319-4639-ba60-ad064bc4596b ce2082c5-1f56-4293-aac4-4a057c6980bc 262495 2025-03-19 15:05:26.162304 2025-03-19 15:10:26.162304
39c31998-35f3-4e8e-aeeb-eb3c1a877a56 960b0c25-4568-4a4a-b45a-1edf4a6dfcfc 341250 2025-04-05 14:59:50.149167 2025-04-05 15:04:50.149167
3ecd4af4-f5e4-476b-83cf-cc4906d9efc4 6b1cf72a-60b3-4f78-ac20-cfc2e75b8512 226002 2025-04-08 13:00:08.830408 2025-04-08 13:05:08.830408
\.
--
-- Name: event_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.event_id_seq', 2, true);
--
-- Name: event_participant_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.event_participant_id_seq', 1, false);
--
-- Name: role_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.role_id_seq', 1, false);
--
-- Name: status_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.status_id_seq', 1, false);
--
-- Name: event_participant event_participant_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.event_participant
ADD CONSTRAINT event_participant_pkey PRIMARY KEY (id);
--
-- Name: event event_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.event
ADD CONSTRAINT event_pkey PRIMARY KEY (id);
--
-- Name: role role_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.role
ADD CONSTRAINT role_name_key UNIQUE (name);
--
-- Name: role role_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.role
ADD CONSTRAINT role_pkey PRIMARY KEY (id);
--
-- Name: status status_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.status
ADD CONSTRAINT status_name_key UNIQUE (name);
--
-- Name: status status_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.status
ADD CONSTRAINT status_pkey PRIMARY KEY (id);
--
-- Name: user_activities user_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_activities
ADD CONSTRAINT user_activities_pkey PRIMARY KEY (id);
--
-- Name: user_photos user_photos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_photos
ADD CONSTRAINT user_photos_pkey PRIMARY KEY (id);
--
-- Name: user_profiles user_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_profiles
ADD CONSTRAINT user_profiles_pkey PRIMARY KEY (user_id);
--
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_email_key UNIQUE (email);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: verification_code verification_code_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.verification_code
ADD CONSTRAINT verification_code_pkey PRIMARY KEY (id);
--
-- Name: idx_user_activities_date; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_user_activities_date ON public.user_activities USING btree (activity_date);
--
-- Name: idx_user_activities_user_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_user_activities_user_id ON public.user_activities USING btree (user_id);
--
-- Name: idx_user_photos_user_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_user_photos_user_id ON public.user_photos USING btree (user_id);
--
-- Name: user_activities trigger_update_activity_stats; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER trigger_update_activity_stats AFTER INSERT OR DELETE OR UPDATE ON public.user_activities FOR EACH ROW EXECUTE FUNCTION public.update_activity_stats();
--
-- Name: event_participant event_participant_event_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.event_participant
ADD CONSTRAINT event_participant_event_id_fkey FOREIGN KEY (event_id) REFERENCES public.event(id);
--
-- Name: user_activities user_activities_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_activities
ADD CONSTRAINT user_activities_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.user_profiles(user_id) ON DELETE CASCADE;
--
-- Name: user_photos user_photos_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_photos
ADD CONSTRAINT user_photos_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.user_profiles(user_id) ON DELETE CASCADE;
--
-- Name: user_profiles user_profiles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_profiles
ADD CONSTRAINT user_profiles_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: users users_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.role(id) ON DELETE CASCADE;
--
-- Name: users users_status_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_status_fkey FOREIGN KEY (status) REFERENCES public.status(id) ON DELETE SET NULL;
--
-- PostgreSQL database dump complete
--
+383
View File
@@ -0,0 +1,383 @@
-- Downloaded from: https://github.com/Dmitrytsg/onectest/blob/427db1e8ecee644c8f52ea16e7b9c608f6d3c375/onecPsqlDB.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 15.7 (Homebrew)
-- Dumped by pg_dump version 15.7 (Homebrew)
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;
--
-- Name: update_statistics(); Type: FUNCTION; Schema: public; Owner: dmitry
--
CREATE FUNCTION public.update_statistics() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
order_date DATE;
product_category INT;
BEGIN
-- Извлекаем дату заказа и категорию товара
order_date := DATE(NEW.order_time);
SELECT category_id INTO product_category FROM products WHERE product_id = NEW.product_id;
-- Проверяем, существует ли запись в статистике за данный день и категорию
IF EXISTS (
SELECT 1 FROM statistics
WHERE date = order_date
AND category_id = product_category
) THEN
-- Если запись существует, обновляем количество товаров
UPDATE statistics
SET product_count = product_count + NEW.number
WHERE date = order_date
AND category_id = product_category;
ELSE
-- Если запись не существует, создаем новую
INSERT INTO statistics (date, category_id, product_count)
VALUES (order_date, product_category, NEW.number);
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.update_statistics() OWNER TO dmitry;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: categories; Type: TABLE; Schema: public; Owner: dmitry
--
CREATE TABLE public.categories (
category_id integer NOT NULL,
category_name character varying(50) NOT NULL
);
ALTER TABLE public.categories OWNER TO dmitry;
--
-- Name: categories_category_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitry
--
CREATE SEQUENCE public.categories_category_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.categories_category_id_seq OWNER TO dmitry;
--
-- Name: categories_category_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitry
--
ALTER SEQUENCE public.categories_category_id_seq OWNED BY public.categories.category_id;
--
-- Name: orders; Type: TABLE; Schema: public; Owner: dmitry
--
CREATE TABLE public.orders (
order_id integer NOT NULL,
order_time timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
product_id integer NOT NULL,
number integer NOT NULL
);
ALTER TABLE public.orders OWNER TO dmitry;
--
-- Name: orders_order_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitry
--
CREATE SEQUENCE public.orders_order_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.orders_order_id_seq OWNER TO dmitry;
--
-- Name: orders_order_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitry
--
ALTER SEQUENCE public.orders_order_id_seq OWNED BY public.orders.order_id;
--
-- Name: products; Type: TABLE; Schema: public; Owner: dmitry
--
CREATE TABLE public.products (
product_id integer NOT NULL,
product_name character varying(100) NOT NULL,
category_id integer NOT NULL,
price numeric(10,2) NOT NULL,
description text
);
ALTER TABLE public.products OWNER TO dmitry;
--
-- Name: products_product_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitry
--
CREATE SEQUENCE public.products_product_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.products_product_id_seq OWNER TO dmitry;
--
-- Name: products_product_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitry
--
ALTER SEQUENCE public.products_product_id_seq OWNED BY public.products.product_id;
--
-- Name: statistics; Type: TABLE; Schema: public; Owner: dmitry
--
CREATE TABLE public.statistics (
stat_id integer NOT NULL,
date date NOT NULL,
category_id integer NOT NULL,
product_count integer NOT NULL
);
ALTER TABLE public.statistics OWNER TO dmitry;
--
-- Name: statistics_stat_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitry
--
CREATE SEQUENCE public.statistics_stat_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.statistics_stat_id_seq OWNER TO dmitry;
--
-- Name: statistics_stat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitry
--
ALTER SEQUENCE public.statistics_stat_id_seq OWNED BY public.statistics.stat_id;
--
-- Name: categories category_id; Type: DEFAULT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.categories ALTER COLUMN category_id SET DEFAULT nextval('public.categories_category_id_seq'::regclass);
--
-- Name: orders order_id; Type: DEFAULT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.orders ALTER COLUMN order_id SET DEFAULT nextval('public.orders_order_id_seq'::regclass);
--
-- Name: products product_id; Type: DEFAULT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.products ALTER COLUMN product_id SET DEFAULT nextval('public.products_product_id_seq'::regclass);
--
-- Name: statistics stat_id; Type: DEFAULT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.statistics ALTER COLUMN stat_id SET DEFAULT nextval('public.statistics_stat_id_seq'::regclass);
--
-- Data for Name: categories; Type: TABLE DATA; Schema: public; Owner: dmitry
--
COPY public.categories (category_id, category_name) FROM stdin;
1 Electronics
2 Books
3 Clothing
\.
--
-- Data for Name: orders; Type: TABLE DATA; Schema: public; Owner: dmitry
--
COPY public.orders (order_id, order_time, product_id, number) FROM stdin;
1 2024-06-20 15:53:18.844677 15 3
2 2024-06-20 15:54:59.915415 14 7
3 2024-06-20 15:54:59.915415 18 4
4 2024-06-20 15:54:59.915415 22 10
5 2024-06-20 15:54:59.915415 21 6
\.
--
-- Data for Name: products; Type: TABLE DATA; Schema: public; Owner: dmitry
--
COPY public.products (product_id, product_name, category_id, price, description) FROM stdin;
13 Smartphone 1 599.99 Latest model with advanced features
14 Laptop 1 999.99 High performance laptop with 16GB RAM
15 Headphones 1 199.99 Noise-cancelling over-ear headphones
16 Tablet 1 299.99 10-inch tablet with high-resolution display
17 E-reader 2 129.99 Portable e-reader with backlit display
18 Novel 2 19.99 Bestselling fiction novel
19 Cookbook 2 24.99 Collection of gourmet recipes
20 Biography 2 29.99 Biography of a famous personality
21 T-shirt 3 14.99 Cotton T-shirt with a graphic print
22 Jeans 3 49.99 Denim jeans with a slim fit
23 Jacket 3 89.99 Waterproof outdoor jacket
24 Sneakers 3 74.99 Comfortable and stylish sneakers
\.
--
-- Data for Name: statistics; Type: TABLE DATA; Schema: public; Owner: dmitry
--
COPY public.statistics (stat_id, date, category_id, product_count) FROM stdin;
1 2024-06-20 1 10
2 2024-06-20 2 4
3 2024-06-20 3 16
\.
--
-- Name: categories_category_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitry
--
SELECT pg_catalog.setval('public.categories_category_id_seq', 3, true);
--
-- Name: orders_order_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitry
--
SELECT pg_catalog.setval('public.orders_order_id_seq', 5, true);
--
-- Name: products_product_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitry
--
SELECT pg_catalog.setval('public.products_product_id_seq', 24, true);
--
-- Name: statistics_stat_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitry
--
SELECT pg_catalog.setval('public.statistics_stat_id_seq', 3, true);
--
-- Name: categories categories_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.categories
ADD CONSTRAINT categories_pkey PRIMARY KEY (category_id);
--
-- Name: orders orders_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.orders
ADD CONSTRAINT orders_pkey PRIMARY KEY (order_id);
--
-- Name: products products_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.products
ADD CONSTRAINT products_pkey PRIMARY KEY (product_id);
--
-- Name: statistics statistics_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.statistics
ADD CONSTRAINT statistics_pkey PRIMARY KEY (stat_id);
--
-- Name: orders after_order_insert; Type: TRIGGER; Schema: public; Owner: dmitry
--
CREATE TRIGGER after_order_insert AFTER INSERT ON public.orders FOR EACH ROW EXECUTE FUNCTION public.update_statistics();
--
-- Name: products fk_category_id; Type: FK CONSTRAINT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.products
ADD CONSTRAINT fk_category_id FOREIGN KEY (category_id) REFERENCES public.categories(category_id) ON UPDATE SET NULL ON DELETE SET NULL;
--
-- Name: statistics fk_category_id; Type: FK CONSTRAINT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.statistics
ADD CONSTRAINT fk_category_id FOREIGN KEY (category_id) REFERENCES public.categories(category_id) ON UPDATE SET NULL ON DELETE SET NULL;
--
-- Name: orders fk_product_id; Type: FK CONSTRAINT; Schema: public; Owner: dmitry
--
ALTER TABLE ONLY public.orders
ADD CONSTRAINT fk_product_id FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON UPDATE SET NULL ON DELETE SET NULL;
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+613
View File
@@ -0,0 +1,613 @@
-- Downloaded from: https://github.com/KangAbbad/laundry-app/blob/78b2c9c3724451e0c767014489eb3c101ef2dc3c/dump_.sql
--
-- PostgreSQL database cluster dump
--
SET default_transaction_read_only = off;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
--
-- Drop databases (except postgres and template1)
--
DROP DATABASE laundryapp;
--
-- Drop roles
--
DROP ROLE postgres;
--
-- Roles
--
CREATE ROLE postgres;
ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS PASSWORD 'SCRAM-SHA-256$4096:I68tB9pBDKM3OrgkD7901A==$hYxpQVMe6Tg+8NrcWCU/8zj/ZV8iin7CZjzT7QN1oUQ=:o+IZGdW7ixEUWk2NysrLj4xA/fHD31yIahmgdmmmkXY=';
--
-- Databases
--
--
-- Database "template1" dump
--
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.5 (Debian 14.5-1.pgdg110+1)
-- Dumped by pg_dump version 14.5 (Debian 14.5-1.pgdg110+1)
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;
UPDATE pg_catalog.pg_database SET datistemplate = false WHERE datname = 'template1';
DROP DATABASE template1;
--
-- Name: template1; Type: DATABASE; Schema: -; Owner: postgres
--
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'en_US.utf8';
ALTER DATABASE template1 OWNER TO postgres;
\connect template1
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;
--
-- Name: DATABASE template1; Type: COMMENT; Schema: -; Owner: postgres
--
COMMENT ON DATABASE template1 IS 'default template for new databases';
--
-- Name: template1; Type: DATABASE PROPERTIES; Schema: -; Owner: postgres
--
ALTER DATABASE template1 IS_TEMPLATE = true;
\connect template1
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;
--
-- Name: DATABASE template1; Type: ACL; Schema: -; Owner: postgres
--
REVOKE CONNECT,TEMPORARY ON DATABASE template1 FROM PUBLIC;
GRANT CONNECT ON DATABASE template1 TO PUBLIC;
--
-- PostgreSQL database dump complete
--
--
-- Database "laundryapp" dump
--
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.5 (Debian 14.5-1.pgdg110+1)
-- Dumped by pg_dump version 14.5 (Debian 14.5-1.pgdg110+1)
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;
--
-- Name: laundryapp; Type: DATABASE; Schema: -; Owner: postgres
--
CREATE DATABASE laundryapp WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'en_US.utf8';
ALTER DATABASE laundryapp OWNER TO postgres;
\connect laundryapp
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;
--
-- Name: today_revenue(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.today_revenue() RETURNS TABLE(admin_id bigint, total_revenue numeric)
LANGUAGE plpgsql
AS $$
begin
return query select t.admin_id, sum(t.total_price) as total_revenue from transactions t where date(created_at) = current_date group by t.admin_id;
end
$$;
ALTER FUNCTION public.today_revenue() OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: admin_roles; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.admin_roles (
admin_id bigint NOT NULL,
role_id bigint NOT NULL
);
ALTER TABLE public.admin_roles OWNER TO postgres;
--
-- Name: admins; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.admins (
id bigint NOT NULL,
address character varying(255),
created_at timestamp without time zone NOT NULL,
email character varying(255) NOT NULL,
id_card character varying(255),
name character varying(255),
password character varying(255),
phone character varying(255) NOT NULL,
updated_at timestamp without time zone NOT NULL,
username character varying(255) NOT NULL
);
ALTER TABLE public.admins OWNER TO postgres;
--
-- Name: admins_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.admins_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.admins_id_seq OWNER TO postgres;
--
-- Name: admins_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.admins_id_seq OWNED BY public.admins.id;
--
-- Name: roles; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.roles (
id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
name character varying(60),
updated_at timestamp without time zone NOT NULL
);
ALTER TABLE public.roles OWNER TO postgres;
--
-- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.roles_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.roles_id_seq OWNER TO postgres;
--
-- Name: roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.roles_id_seq OWNED BY public.roles.id;
--
-- Name: summary_revenue; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.summary_revenue (
id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
total_revenue numeric(19,2),
updated_at timestamp without time zone NOT NULL,
admin_id bigint
);
ALTER TABLE public.summary_revenue OWNER TO postgres;
--
-- Name: summary_revenue_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.summary_revenue_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.summary_revenue_id_seq OWNER TO postgres;
--
-- Name: summary_revenue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.summary_revenue_id_seq OWNED BY public.summary_revenue.id;
--
-- Name: transactions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.transactions (
id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
notes text,
status integer,
total_price numeric(19,2),
updated_at timestamp without time zone NOT NULL,
weight integer NOT NULL,
admin_id bigint
);
ALTER TABLE public.transactions OWNER TO postgres;
--
-- Name: transactions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.transactions_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.transactions_id_seq OWNER TO postgres;
--
-- Name: transactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.transactions_id_seq OWNED BY public.transactions.id;
--
-- Name: admins id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admins ALTER COLUMN id SET DEFAULT nextval('public.admins_id_seq'::regclass);
--
-- Name: roles id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_id_seq'::regclass);
--
-- Name: summary_revenue id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.summary_revenue ALTER COLUMN id SET DEFAULT nextval('public.summary_revenue_id_seq'::regclass);
--
-- Name: transactions id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.transactions ALTER COLUMN id SET DEFAULT nextval('public.transactions_id_seq'::regclass);
--
-- Data for Name: admin_roles; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.admin_roles (admin_id, role_id) FROM stdin;
1 1
2 1
\.
--
-- Data for Name: admins; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.admins (id, address, created_at, email, id_card, name, password, phone, updated_at, username) FROM stdin;
1 Laweyan, Solo 2022-09-12 09:57:01.477 email1@email.com 3333123456789 User 01 $2a$10$Cs3WOQOCwA/3LznT89HzAOF7eZevbWpI5/k1diqZ7swM5OQOOe3ai 08123456789 2022-09-12 09:57:01.477 user01
2 Laweyan, Solo 2022-09-12 12:29:47.912 email2@email.com 333312345678910 User 02 $2a$10$ioACrSPTM8ZT1AOYfQiT/.3tL.swZ.f7nfz/iZs996bpDXAxrUOiS 0812345678910 2022-09-12 12:29:47.912 user02
\.
--
-- Data for Name: roles; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.roles (id, created_at, name, updated_at) FROM stdin;
1 2022-09-12 09:47:52.930144 ROLE_ADMIN 2022-09-12 09:47:52.930144
\.
--
-- Data for Name: summary_revenue; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.summary_revenue (id, created_at, total_revenue, updated_at, admin_id) FROM stdin;
1 2022-09-12 12:18:12.169 45000.00 2022-09-12 18:45:54.121 1
2 2022-09-12 12:30:00.031 30000.00 2022-09-12 18:45:54.124 2
\.
--
-- Data for Name: transactions; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.transactions (id, created_at, notes, status, total_price, updated_at, weight, admin_id) FROM stdin;
1 2022-09-12 09:57:32.101 Transaksi 1 Admin 1 0 15000.00 2022-09-12 09:57:32.101 3 1
2 2022-09-12 11:19:18.994 Transaksi 2 Admin 1 0 15000.00 2022-09-12 11:19:18.994 3 1
3 2022-09-12 12:10:02.213 Transaksi 3 Admin 1 0 15000.00 2022-09-12 12:10:02.213 3 1
4 2022-09-12 12:29:57.164 Transaksi 1 Admin 2 0 15000.00 2022-09-12 12:29:57.164 3 2
5 2022-09-12 12:31:07.836 Transaksi 2 Admin 2 0 15000.00 2022-09-12 12:31:07.836 3 2
\.
--
-- Name: admins_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.admins_id_seq', 2, true);
--
-- Name: roles_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.roles_id_seq', 1, true);
--
-- Name: summary_revenue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.summary_revenue_id_seq', 2, true);
--
-- Name: transactions_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.transactions_id_seq', 5, true);
--
-- Name: admin_roles admin_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admin_roles
ADD CONSTRAINT admin_roles_pkey PRIMARY KEY (admin_id, role_id);
--
-- Name: admins admins_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admins
ADD CONSTRAINT admins_pkey PRIMARY KEY (id);
--
-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.roles
ADD CONSTRAINT roles_pkey PRIMARY KEY (id);
--
-- Name: summary_revenue summary_revenue_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.summary_revenue
ADD CONSTRAINT summary_revenue_pkey PRIMARY KEY (id);
--
-- Name: transactions transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.transactions
ADD CONSTRAINT transactions_pkey PRIMARY KEY (id);
--
-- Name: admins uk_40k3ldiov4eh6w3vk8046lic; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admins
ADD CONSTRAINT uk_40k3ldiov4eh6w3vk8046lic UNIQUE (email, phone, username);
--
-- Name: roles uk_nb4h0p6txrmfc0xbrd1kglp9t; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.roles
ADD CONSTRAINT uk_nb4h0p6txrmfc0xbrd1kglp9t UNIQUE (name);
--
-- Name: admin_roles fk3liyab508sfblqps0eqjhmjqk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admin_roles
ADD CONSTRAINT fk3liyab508sfblqps0eqjhmjqk FOREIGN KEY (role_id) REFERENCES public.roles(id);
--
-- Name: transactions fkcld5louxmdqxvivbradq5g23r; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.transactions
ADD CONSTRAINT fkcld5louxmdqxvivbradq5g23r FOREIGN KEY (admin_id) REFERENCES public.admins(id);
--
-- Name: admin_roles fkghcw89q6jebq3c6kocnobjusr; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admin_roles
ADD CONSTRAINT fkghcw89q6jebq3c6kocnobjusr FOREIGN KEY (admin_id) REFERENCES public.admins(id);
--
-- Name: summary_revenue fksg88fdt3bygok7vqpdeno6jly; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.summary_revenue
ADD CONSTRAINT fksg88fdt3bygok7vqpdeno6jly FOREIGN KEY (admin_id) REFERENCES public.admins(id);
--
-- PostgreSQL database dump complete
--
--
-- Database "postgres" dump
--
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.5 (Debian 14.5-1.pgdg110+1)
-- Dumped by pg_dump version 14.5 (Debian 14.5-1.pgdg110+1)
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;
DROP DATABASE postgres;
--
-- Name: postgres; Type: DATABASE; Schema: -; Owner: postgres
--
CREATE DATABASE postgres WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'en_US.utf8';
ALTER DATABASE postgres OWNER TO postgres;
\connect postgres
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;
--
-- Name: DATABASE postgres; Type: COMMENT; Schema: -; Owner: postgres
--
COMMENT ON DATABASE postgres IS 'default administrative connection database';
--
-- PostgreSQL database dump complete
--
--
-- PostgreSQL database cluster dump complete
--
@@ -0,0 +1,480 @@
-- Downloaded from: https://github.com/Mistral-war2ru/PG-connect/blob/ba0e4f62b6b9b5799cf645fdc072d59f727b9ffe/lab9/TestDB.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 15.2
-- Dumped by pg_dump version 15.2
-- Started on 2023-04-19 19:40:00
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;
--
-- TOC entry 3370 (class 1262 OID 25411)
-- Name: StudentsDB; Type: DATABASE; Schema: -; Owner: postgres
--
CREATE DATABASE "StudentsDB" WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'Russian_Russia.1251';
ALTER DATABASE "StudentsDB" OWNER TO postgres;
\connect "StudentsDB"
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;
--
-- TOC entry 3371 (class 0 OID 0)
-- Name: StudentsDB; Type: DATABASE PROPERTIES; Schema: -; Owner: postgres
--
ALTER ROLE postgres IN DATABASE "StudentsDB" SET effective_cache_size TO '65536';
\connect "StudentsDB"
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;
--
-- TOC entry 223 (class 1255 OID 25412)
-- Name: get_fiit_2019(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.get_fiit_2019() RETURNS text
LANGUAGE plpgsql
AS $$
declare
ret text default '';
rec record;
curs refcursor;
begin
--call proc1(curs, 2019, 'ФИИТ');
call proc1(curs, 2018, 'ФИИТ');
loop
fetch curs into rec;
exit when not found;
ret := ret || '{' || rec.SpecialtyName || ',' || rec.SetName|| ',' || rec.GroupName || ',' || rec.SetYear|| '}';
end loop;
close curs;
return ret;
end; $$;
ALTER FUNCTION public.get_fiit_2019() OWNER TO postgres;
--
-- TOC entry 224 (class 1255 OID 25413)
-- Name: proc1(refcursor); Type: PROCEDURE; Schema: public; Owner: postgres
--
CREATE PROCEDURE public.proc1(INOUT curs refcursor)
LANGUAGE plpgsql
AS $$
DECLARE
lcurs refcursor;
BEGIN
open lcurs for
select SpecialtyName, SetName, GroupName, SetYear
from Groups inner join (Sets inner join Specialities on Sets.SpecialtyID = Specialities.SpecialtyID) on Sets.SetID = Groups.SetID
where Sets.SetYear = 2019 AND Specialities.SpecialtyCode = 'ФИИТ';
curs = lcurs;
END $$;
ALTER PROCEDURE public.proc1(INOUT curs refcursor) OWNER TO postgres;
--
-- TOC entry 225 (class 1255 OID 25414)
-- Name: proc1(refcursor, integer, text); Type: PROCEDURE; Schema: public; Owner: postgres
--
CREATE PROCEDURE public.proc1(INOUT curs refcursor, IN yr integer, IN spec text)
LANGUAGE plpgsql
AS $$
DECLARE
lcurs refcursor;
BEGIN
open lcurs for
select SpecialtyName, SetName, GroupName, SetYear
from Groups inner join (Sets inner join Specialities on Sets.SpecialtyID = Specialities.SpecialtyID) on Sets.SetID = Groups.SetID
where Sets.SetYear = yr AND Specialities.SpecialtyCode = spec;
curs = lcurs;
END $$;
ALTER PROCEDURE public.proc1(INOUT curs refcursor, IN yr integer, IN spec text) OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 214 (class 1259 OID 25415)
-- Name: groups; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.groups (
groupid integer NOT NULL,
setid integer NOT NULL,
groupname text NOT NULL,
teachformid integer NOT NULL
);
ALTER TABLE public.groups OWNER TO postgres;
--
-- TOC entry 215 (class 1259 OID 25420)
-- Name: groups_groupid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.groups ALTER COLUMN groupid ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.groups_groupid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 221 (class 1259 OID 25462)
-- Name: labs; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.labs (
"ID" integer NOT NULL,
"Name" text NOT NULL
);
ALTER TABLE public.labs OWNER TO postgres;
--
-- TOC entry 222 (class 1259 OID 25469)
-- Name: labs_ID_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.labs ALTER COLUMN "ID" ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public."labs_ID_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 216 (class 1259 OID 25421)
-- Name: sets; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.sets (
setid integer NOT NULL,
setname text NOT NULL,
setyear integer NOT NULL,
specialtyid integer NOT NULL
);
ALTER TABLE public.sets OWNER TO postgres;
--
-- TOC entry 217 (class 1259 OID 25426)
-- Name: sets_setid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.sets ALTER COLUMN setid ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.sets_setid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 218 (class 1259 OID 25427)
-- Name: specialities; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.specialities (
specialtyid integer NOT NULL,
specialtyname text NOT NULL,
specialtycode text NOT NULL,
descript text
);
ALTER TABLE public.specialities OWNER TO postgres;
--
-- TOC entry 219 (class 1259 OID 25432)
-- Name: specialities_specialtyid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.specialities ALTER COLUMN specialtyid ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.specialities_specialtyid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 220 (class 1259 OID 25458)
-- Name: v1; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW public.v1 AS
SELECT groups.groupname,
sets.setname,
sets.setyear,
specialities.specialtycode
FROM (public.groups
JOIN (public.sets
JOIN public.specialities ON ((specialities.specialtyid = sets.specialtyid))) ON ((sets.setid = groups.setid)));
ALTER TABLE public.v1 OWNER TO postgres;
--
-- TOC entry 3357 (class 0 OID 25415)
-- Dependencies: 214
-- Data for Name: groups; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (3, 2, 'ПИ-20-а', 1);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (4, 2, 'ПИ-20-б', 1);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (7, 4, 'ФИИТ-16-а', 1);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (8, 4, 'ФИИТ-16-б', 1);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (9, 5, 'ФИИТ-18-а', 1);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (10, 5, 'ФИИТ-18-б', 1);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (12, 6, 'ФИИТ-20-а', 1);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (13, 6, 'ФИИТ-20-б', 1);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (11, 5, 'ФИИТ-18-в', 2);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (14, 6, 'ФИИТ-20-в', 2);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (15, 1, 'ПМ-20-1', 2);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (16, 1, 'ПМ-20-2', 2);
INSERT INTO public.groups OVERRIDING SYSTEM VALUE VALUES (18, 2, 'test', 2);
--
-- TOC entry 3363 (class 0 OID 25462)
-- Dependencies: 221
-- Data for Name: labs; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.labs OVERRIDING SYSTEM VALUE VALUES (1, 'lab1');
INSERT INTO public.labs OVERRIDING SYSTEM VALUE VALUES (2, 'lab2');
--
-- TOC entry 3359 (class 0 OID 25421)
-- Dependencies: 216
-- Data for Name: sets; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.sets OVERRIDING SYSTEM VALUE VALUES (1, 'ПИ-15', 2015, 1);
INSERT INTO public.sets OVERRIDING SYSTEM VALUE VALUES (2, 'ПИ-20', 2020, 2);
INSERT INTO public.sets OVERRIDING SYSTEM VALUE VALUES (3, 'ФИИТ-15', 2015, 3);
INSERT INTO public.sets OVERRIDING SYSTEM VALUE VALUES (4, 'ФИИТ-16', 2016, 3);
INSERT INTO public.sets OVERRIDING SYSTEM VALUE VALUES (5, 'ФИИТ-18', 2018, 3);
INSERT INTO public.sets OVERRIDING SYSTEM VALUE VALUES (6, 'ФИИТ-20', 2019, 3);
INSERT INTO public.sets OVERRIDING SYSTEM VALUE VALUES (7, 'name12', 2016, 10);
--
-- TOC entry 3361 (class 0 OID 25427)
-- Dependencies: 218
-- Data for Name: specialities; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.specialities OVERRIDING SYSTEM VALUE VALUES (3, 'Фундаментальная информатика и ИТ', 'ФИИТ', 'Кафедра ВТ');
INSERT INTO public.specialities OVERRIDING SYSTEM VALUE VALUES (1, 'Прикладная информатика', 'ПИ', 'Кафедра ПМИ');
INSERT INTO public.specialities OVERRIDING SYSTEM VALUE VALUES (2, 'Прикладная математика и информатика', 'ПМИ', 'Кафедра ПМИ');
INSERT INTO public.specialities OVERRIDING SYSTEM VALUE VALUES (10, 'test1', 'test2', 'test3');
--
-- TOC entry 3372 (class 0 OID 0)
-- Dependencies: 215
-- Name: groups_groupid_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.groups_groupid_seq', 18, true);
--
-- TOC entry 3373 (class 0 OID 0)
-- Dependencies: 222
-- Name: labs_ID_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public."labs_ID_seq"', 10, true);
--
-- TOC entry 3374 (class 0 OID 0)
-- Dependencies: 217
-- Name: sets_setid_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.sets_setid_seq', 7, true);
--
-- TOC entry 3375 (class 0 OID 0)
-- Dependencies: 219
-- Name: specialities_specialtyid_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.specialities_specialtyid_seq', 10, true);
--
-- TOC entry 3196 (class 2606 OID 25434)
-- Name: groups groups_groupid_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.groups
ADD CONSTRAINT groups_groupid_key UNIQUE (groupid);
--
-- TOC entry 3211 (class 2606 OID 25468)
-- Name: labs labs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.labs
ADD CONSTRAINT labs_pkey PRIMARY KEY ("ID");
--
-- TOC entry 3199 (class 2606 OID 25436)
-- Name: groups pkgroups; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.groups
ADD CONSTRAINT pkgroups PRIMARY KEY (groupid);
--
-- TOC entry 3202 (class 2606 OID 25438)
-- Name: sets pksets; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.sets
ADD CONSTRAINT pksets PRIMARY KEY (setid);
--
-- TOC entry 3206 (class 2606 OID 25440)
-- Name: specialities pkspecialities; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.specialities
ADD CONSTRAINT pkspecialities PRIMARY KEY (specialtyid);
--
-- TOC entry 3204 (class 2606 OID 25442)
-- Name: sets sets_setid_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.sets
ADD CONSTRAINT sets_setid_key UNIQUE (setid);
--
-- TOC entry 3208 (class 2606 OID 25444)
-- Name: specialities specialities_specialtyid_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.specialities
ADD CONSTRAINT specialities_specialtyid_key UNIQUE (specialtyid);
--
-- TOC entry 3197 (class 1259 OID 25445)
-- Name: igroupsteachformid; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX igroupsteachformid ON public.groups USING btree (teachformid);
--
-- TOC entry 3200 (class 1259 OID 25446)
-- Name: isetssetyear; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX isetssetyear ON public.sets USING btree (setyear);
--
-- TOC entry 3209 (class 1259 OID 25447)
-- Name: specialtyindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX specialtyindex ON public.specialities USING btree (specialtyid);
ALTER TABLE public.specialities CLUSTER ON specialtyindex;
--
-- TOC entry 3212 (class 2606 OID 25448)
-- Name: groups fkgroupssets; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.groups
ADD CONSTRAINT fkgroupssets FOREIGN KEY (setid) REFERENCES public.sets(setid) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3213 (class 2606 OID 25453)
-- Name: sets fksetsspecialities; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.sets
ADD CONSTRAINT fksetsspecialities FOREIGN KEY (specialtyid) REFERENCES public.specialities(specialtyid) ON UPDATE CASCADE;
-- Completed on 2023-04-19 19:40:00
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,724 @@
-- Downloaded from: https://github.com/TaraPadilla/MarketSpring/blob/84bf503f29fa1db3c3f4ee5acfdb7bbb59fd0f39/docs/bdmarket.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.4
-- Dumped by pg_dump version 16.4
-- Started on 2024-08-26 18:11:04
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;
--
-- TOC entry 6 (class 2615 OID 16595)
-- Name: base; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA base;
ALTER SCHEMA base OWNER TO postgres;
--
-- TOC entry 9 (class 2615 OID 17248)
-- Name: comercial; Type: SCHEMA; Schema: -; Owner: ebroot
--
CREATE SCHEMA comercial;
ALTER SCHEMA comercial OWNER TO ebroot;
--
-- TOC entry 7 (class 2615 OID 16596)
-- Name: products; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA products;
ALTER SCHEMA products OWNER TO postgres;
--
-- TOC entry 8 (class 2615 OID 16597)
-- Name: services; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA services;
ALTER SCHEMA services OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 223 (class 1259 OID 16505)
-- Name: clientes; Type: TABLE; Schema: base; Owner: ebroot
--
CREATE TABLE base.clientes (
id character varying(255) NOT NULL,
nombre character varying(255),
apellidos character varying(255),
celular double precision,
direccion character varying(255),
correo_electronico character varying(255)
);
ALTER TABLE base.clientes OWNER TO ebroot;
--
-- TOC entry 226 (class 1259 OID 16514)
-- Name: compras; Type: TABLE; Schema: base; Owner: ebroot
--
CREATE TABLE base.compras (
id_compra integer NOT NULL,
id_cliente character varying(255) NOT NULL,
fecha timestamp without time zone,
medio_pago character varying(1),
comentario character varying(255),
estado character varying(1)
);
ALTER TABLE base.compras OWNER TO ebroot;
--
-- TOC entry 227 (class 1259 OID 16519)
-- Name: compras_id_compra_seq; Type: SEQUENCE; Schema: base; Owner: ebroot
--
CREATE SEQUENCE base.compras_id_compra_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE base.compras_id_compra_seq OWNER TO ebroot;
--
-- TOC entry 4943 (class 0 OID 0)
-- Dependencies: 227
-- Name: compras_id_compra_seq; Type: SEQUENCE OWNED BY; Schema: base; Owner: ebroot
--
ALTER SEQUENCE base.compras_id_compra_seq OWNED BY base.compras.id_compra;
--
-- TOC entry 236 (class 1259 OID 16841)
-- Name: empresa; Type: TABLE; Schema: base; Owner: postgres
--
CREATE TABLE base.empresa (
id_empresa integer NOT NULL,
nombre character varying(255) NOT NULL,
descripcion character varying NOT NULL,
estado boolean DEFAULT true
);
ALTER TABLE base.empresa OWNER TO postgres;
--
-- TOC entry 235 (class 1259 OID 16840)
-- Name: empresa_id_empresa_seq; Type: SEQUENCE; Schema: base; Owner: postgres
--
ALTER TABLE base.empresa ALTER COLUMN id_empresa ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME base.empresa_id_empresa_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 240 (class 1259 OID 17407)
-- Name: usuario; Type: TABLE; Schema: base; Owner: postgres
--
CREATE TABLE base.usuario (
id_usuario integer NOT NULL,
id_empresa integer NOT NULL
);
ALTER TABLE base.usuario OWNER TO postgres;
--
-- TOC entry 229 (class 1259 OID 16523)
-- Name: cotizacion; Type: TABLE; Schema: comercial; Owner: ebroot
--
CREATE TABLE comercial.cotizacion (
id_cotizacion integer NOT NULL,
estado character varying(255) NOT NULL,
fecha_creacion timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
notas character varying(255),
precio_total numeric(6,2) NOT NULL,
id_catalogo integer,
id_servicio integer,
id_usuario integer
);
ALTER TABLE comercial.cotizacion OWNER TO ebroot;
--
-- TOC entry 230 (class 1259 OID 16529)
-- Name: cotizacion_id_cotizacion_seq; Type: SEQUENCE; Schema: comercial; Owner: ebroot
--
ALTER TABLE comercial.cotizacion ALTER COLUMN id_cotizacion ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME comercial.cotizacion_id_cotizacion_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 238 (class 1259 OID 17156)
-- Name: catalogo; Type: TABLE; Schema: products; Owner: postgres
--
CREATE TABLE products.catalogo (
id_catalogo integer NOT NULL,
id_empresa integer,
nombre character varying(255) NOT NULL
);
ALTER TABLE products.catalogo OWNER TO postgres;
--
-- TOC entry 237 (class 1259 OID 17155)
-- Name: catalogo_id_catalogo_seq; Type: SEQUENCE; Schema: products; Owner: postgres
--
ALTER TABLE products.catalogo ALTER COLUMN id_catalogo ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME products.catalogo_id_catalogo_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 239 (class 1259 OID 17392)
-- Name: catalogo_productos; Type: TABLE; Schema: products; Owner: postgres
--
CREATE TABLE products.catalogo_productos (
id_catalogo integer NOT NULL,
id_producto integer NOT NULL
);
ALTER TABLE products.catalogo_productos OWNER TO postgres;
--
-- TOC entry 221 (class 1259 OID 16501)
-- Name: categorias; Type: TABLE; Schema: products; Owner: ebroot
--
CREATE TABLE products.categorias (
id_categoria integer NOT NULL,
descripcion character varying(255) NOT NULL,
estado boolean NOT NULL
);
ALTER TABLE products.categorias OWNER TO ebroot;
--
-- TOC entry 222 (class 1259 OID 16504)
-- Name: categorias_id_categoria_seq; Type: SEQUENCE; Schema: products; Owner: ebroot
--
CREATE SEQUENCE products.categorias_id_categoria_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE products.categorias_id_categoria_seq OWNER TO ebroot;
--
-- TOC entry 4944 (class 0 OID 0)
-- Dependencies: 222
-- Name: categorias_id_categoria_seq; Type: SEQUENCE OWNED BY; Schema: products; Owner: ebroot
--
ALTER SEQUENCE products.categorias_id_categoria_seq OWNED BY products.categorias.id_categoria;
--
-- TOC entry 228 (class 1259 OID 16520)
-- Name: compras_productos; Type: TABLE; Schema: products; Owner: ebroot
--
CREATE TABLE products.compras_productos (
id_compra integer NOT NULL,
id_producto integer NOT NULL,
cantidad integer,
total numeric(38,2),
estado boolean
);
ALTER TABLE products.compras_productos OWNER TO ebroot;
--
-- TOC entry 231 (class 1259 OID 16530)
-- Name: productos; Type: TABLE; Schema: products; Owner: ebroot
--
CREATE TABLE products.productos (
id_producto integer NOT NULL,
nombre character varying(255),
id_categoria integer NOT NULL,
codigo_barras character varying(255),
precio_venta numeric(38,2),
cantidad_stock integer NOT NULL,
estado boolean
);
ALTER TABLE products.productos OWNER TO ebroot;
--
-- TOC entry 232 (class 1259 OID 16535)
-- Name: productos_id_producto_seq; Type: SEQUENCE; Schema: products; Owner: ebroot
--
CREATE SEQUENCE products.productos_id_producto_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE products.productos_id_producto_seq OWNER TO ebroot;
--
-- TOC entry 4945 (class 0 OID 0)
-- Dependencies: 232
-- Name: productos_id_producto_seq; Type: SEQUENCE OWNED BY; Schema: products; Owner: ebroot
--
ALTER SEQUENCE products.productos_id_producto_seq OWNED BY products.productos.id_producto;
--
-- TOC entry 219 (class 1259 OID 16497)
-- Name: caracteristica; Type: TABLE; Schema: services; Owner: ebroot
--
CREATE TABLE services.caracteristica (
id_caracteristica integer NOT NULL,
descripcion character varying(255) NOT NULL,
nombre character varying(50) NOT NULL,
id_servicio integer
);
ALTER TABLE services.caracteristica OWNER TO ebroot;
--
-- TOC entry 220 (class 1259 OID 16500)
-- Name: caracteristica_id_caracteristica_seq; Type: SEQUENCE; Schema: services; Owner: ebroot
--
ALTER TABLE services.caracteristica ALTER COLUMN id_caracteristica ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME services.caracteristica_id_caracteristica_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 224 (class 1259 OID 16510)
-- Name: componente; Type: TABLE; Schema: services; Owner: ebroot
--
CREATE TABLE services.componente (
id_componente integer NOT NULL,
descripcion character varying(255) NOT NULL,
nombre character varying(50) NOT NULL,
precio numeric(6,2) NOT NULL,
id_servicio integer
);
ALTER TABLE services.componente OWNER TO ebroot;
--
-- TOC entry 225 (class 1259 OID 16513)
-- Name: componente_id_componente_seq; Type: SEQUENCE; Schema: services; Owner: ebroot
--
ALTER TABLE services.componente ALTER COLUMN id_componente ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME services.componente_id_componente_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 233 (class 1259 OID 16536)
-- Name: servicio; Type: TABLE; Schema: services; Owner: ebroot
--
CREATE TABLE services.servicio (
id_servicio integer NOT NULL,
descripcion character varying(150) NOT NULL,
nombre_servicio character varying(30) NOT NULL,
visible boolean NOT NULL,
id_empresa integer
);
ALTER TABLE services.servicio OWNER TO ebroot;
--
-- TOC entry 4946 (class 0 OID 0)
-- Dependencies: 233
-- Name: COLUMN servicio.id_empresa; Type: COMMENT; Schema: services; Owner: ebroot
--
COMMENT ON COLUMN services.servicio.id_empresa IS 'Empresa que presta este servicio';
--
-- TOC entry 234 (class 1259 OID 16539)
-- Name: servicio_id_cotizacion_seq; Type: SEQUENCE; Schema: services; Owner: ebroot
--
ALTER TABLE services.servicio ALTER COLUMN id_servicio ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME services.servicio_id_cotizacion_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 4749 (class 2604 OID 16541)
-- Name: compras id_compra; Type: DEFAULT; Schema: base; Owner: ebroot
--
ALTER TABLE ONLY base.compras ALTER COLUMN id_compra SET DEFAULT nextval('base.compras_id_compra_seq'::regclass);
--
-- TOC entry 4748 (class 2604 OID 16540)
-- Name: categorias id_categoria; Type: DEFAULT; Schema: products; Owner: ebroot
--
ALTER TABLE ONLY products.categorias ALTER COLUMN id_categoria SET DEFAULT nextval('products.categorias_id_categoria_seq'::regclass);
--
-- TOC entry 4751 (class 2604 OID 16542)
-- Name: productos id_producto; Type: DEFAULT; Schema: products; Owner: ebroot
--
ALTER TABLE ONLY products.productos ALTER COLUMN id_producto SET DEFAULT nextval('products.productos_id_producto_seq'::regclass);
--
-- TOC entry 4758 (class 2606 OID 16548)
-- Name: clientes clientes_pkey; Type: CONSTRAINT; Schema: base; Owner: ebroot
--
ALTER TABLE ONLY base.clientes
ADD CONSTRAINT clientes_pkey PRIMARY KEY (id);
--
-- TOC entry 4762 (class 2606 OID 16552)
-- Name: compras compras_pkey; Type: CONSTRAINT; Schema: base; Owner: ebroot
--
ALTER TABLE ONLY base.compras
ADD CONSTRAINT compras_pkey PRIMARY KEY (id_compra);
--
-- TOC entry 4774 (class 2606 OID 16848)
-- Name: empresa pk_empresa; Type: CONSTRAINT; Schema: base; Owner: postgres
--
ALTER TABLE ONLY base.empresa
ADD CONSTRAINT pk_empresa PRIMARY KEY (id_empresa);
--
-- TOC entry 4780 (class 2606 OID 17416)
-- Name: usuario unq_usuario_id_usuario; Type: CONSTRAINT; Schema: base; Owner: postgres
--
ALTER TABLE ONLY base.usuario
ADD CONSTRAINT unq_usuario_id_usuario UNIQUE (id_usuario);
--
-- TOC entry 4766 (class 2606 OID 16556)
-- Name: cotizacion cotizacion_pkey; Type: CONSTRAINT; Schema: comercial; Owner: ebroot
--
ALTER TABLE ONLY comercial.cotizacion
ADD CONSTRAINT cotizacion_pkey PRIMARY KEY (id_cotizacion);
--
-- TOC entry 4756 (class 2606 OID 16546)
-- Name: categorias categorias_pkey; Type: CONSTRAINT; Schema: products; Owner: ebroot
--
ALTER TABLE ONLY products.categorias
ADD CONSTRAINT categorias_pkey PRIMARY KEY (id_categoria);
--
-- TOC entry 4764 (class 2606 OID 16554)
-- Name: compras_productos compras_productos_pkey; Type: CONSTRAINT; Schema: products; Owner: ebroot
--
ALTER TABLE ONLY products.compras_productos
ADD CONSTRAINT compras_productos_pkey PRIMARY KEY (id_compra, id_producto);
--
-- TOC entry 4776 (class 2606 OID 17160)
-- Name: catalogo pk_catalogo; Type: CONSTRAINT; Schema: products; Owner: postgres
--
ALTER TABLE ONLY products.catalogo
ADD CONSTRAINT pk_catalogo PRIMARY KEY (id_catalogo);
--
-- TOC entry 4768 (class 2606 OID 16558)
-- Name: productos productos_pkey; Type: CONSTRAINT; Schema: products; Owner: ebroot
--
ALTER TABLE ONLY products.productos
ADD CONSTRAINT productos_pkey PRIMARY KEY (id_producto);
--
-- TOC entry 4778 (class 2606 OID 17396)
-- Name: catalogo_productos unq_catalogo_productos_id_catalogo; Type: CONSTRAINT; Schema: products; Owner: postgres
--
ALTER TABLE ONLY products.catalogo_productos
ADD CONSTRAINT unq_catalogo_productos_id_catalogo UNIQUE (id_catalogo);
--
-- TOC entry 4754 (class 2606 OID 16544)
-- Name: caracteristica caracteristica_pkey; Type: CONSTRAINT; Schema: services; Owner: ebroot
--
ALTER TABLE ONLY services.caracteristica
ADD CONSTRAINT caracteristica_pkey PRIMARY KEY (id_caracteristica);
--
-- TOC entry 4760 (class 2606 OID 16550)
-- Name: componente componente_pkey; Type: CONSTRAINT; Schema: services; Owner: ebroot
--
ALTER TABLE ONLY services.componente
ADD CONSTRAINT componente_pkey PRIMARY KEY (id_componente);
--
-- TOC entry 4770 (class 2606 OID 16560)
-- Name: servicio servicio_pkey; Type: CONSTRAINT; Schema: services; Owner: ebroot
--
ALTER TABLE ONLY services.servicio
ADD CONSTRAINT servicio_pkey PRIMARY KEY (id_servicio);
--
-- TOC entry 4772 (class 2606 OID 16562)
-- Name: servicio ukngllnswut8q6wwg87y95egn41; Type: CONSTRAINT; Schema: services; Owner: ebroot
--
ALTER TABLE ONLY services.servicio
ADD CONSTRAINT ukngllnswut8q6wwg87y95egn41 UNIQUE (nombre_servicio);
--
-- TOC entry 4783 (class 2606 OID 16563)
-- Name: compras fk_COMPRAS_CLIENTES1; Type: FK CONSTRAINT; Schema: base; Owner: ebroot
--
ALTER TABLE ONLY base.compras
ADD CONSTRAINT "fk_COMPRAS_CLIENTES1" FOREIGN KEY (id_cliente) REFERENCES base.clientes(id);
--
-- TOC entry 4794 (class 2606 OID 17410)
-- Name: usuario fk_usuario_empresa; Type: FK CONSTRAINT; Schema: base; Owner: postgres
--
ALTER TABLE ONLY base.usuario
ADD CONSTRAINT fk_usuario_empresa FOREIGN KEY (id_empresa) REFERENCES base.empresa(id_empresa);
--
-- TOC entry 4786 (class 2606 OID 17194)
-- Name: cotizacion fk_cotizacion_catalogo; Type: FK CONSTRAINT; Schema: comercial; Owner: ebroot
--
ALTER TABLE ONLY comercial.cotizacion
ADD CONSTRAINT fk_cotizacion_catalogo FOREIGN KEY (id_catalogo) REFERENCES products.catalogo(id_catalogo);
--
-- TOC entry 4787 (class 2606 OID 17199)
-- Name: cotizacion fk_cotizacion_servicio; Type: FK CONSTRAINT; Schema: comercial; Owner: ebroot
--
ALTER TABLE ONLY comercial.cotizacion
ADD CONSTRAINT fk_cotizacion_servicio FOREIGN KEY (id_servicio) REFERENCES services.servicio(id_servicio);
--
-- TOC entry 4788 (class 2606 OID 17417)
-- Name: cotizacion fk_cotizacion_usuario; Type: FK CONSTRAINT; Schema: comercial; Owner: ebroot
--
ALTER TABLE ONLY comercial.cotizacion
ADD CONSTRAINT fk_cotizacion_usuario FOREIGN KEY (id_usuario) REFERENCES base.usuario(id_usuario);
--
-- TOC entry 4784 (class 2606 OID 16568)
-- Name: compras_productos fk_COMPRAS_PRODUCTOS_COMPRAS1; Type: FK CONSTRAINT; Schema: products; Owner: ebroot
--
ALTER TABLE ONLY products.compras_productos
ADD CONSTRAINT "fk_COMPRAS_PRODUCTOS_COMPRAS1" FOREIGN KEY (id_compra) REFERENCES base.compras(id_compra);
--
-- TOC entry 4785 (class 2606 OID 16573)
-- Name: compras_productos fk_COMPRAS_PRODUCTOS_PRODUCTOS1; Type: FK CONSTRAINT; Schema: products; Owner: ebroot
--
ALTER TABLE ONLY products.compras_productos
ADD CONSTRAINT "fk_COMPRAS_PRODUCTOS_PRODUCTOS1" FOREIGN KEY (id_producto) REFERENCES products.productos(id_producto);
--
-- TOC entry 4789 (class 2606 OID 16578)
-- Name: productos fk_PRODUCTOS_CATEGORIAS; Type: FK CONSTRAINT; Schema: products; Owner: ebroot
--
ALTER TABLE ONLY products.productos
ADD CONSTRAINT "fk_PRODUCTOS_CATEGORIAS" FOREIGN KEY (id_categoria) REFERENCES products.categorias(id_categoria);
--
-- TOC entry 4791 (class 2606 OID 17397)
-- Name: catalogo fk_catalogo_catalogo_productos; Type: FK CONSTRAINT; Schema: products; Owner: postgres
--
ALTER TABLE ONLY products.catalogo
ADD CONSTRAINT fk_catalogo_catalogo_productos FOREIGN KEY (id_catalogo) REFERENCES products.catalogo_productos(id_catalogo);
--
-- TOC entry 4792 (class 2606 OID 17161)
-- Name: catalogo fk_catalogo_empresa; Type: FK CONSTRAINT; Schema: products; Owner: postgres
--
ALTER TABLE ONLY products.catalogo
ADD CONSTRAINT fk_catalogo_empresa FOREIGN KEY (id_empresa) REFERENCES base.empresa(id_empresa) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- TOC entry 4793 (class 2606 OID 17402)
-- Name: catalogo_productos fk_catalogo_productos_productos; Type: FK CONSTRAINT; Schema: products; Owner: postgres
--
ALTER TABLE ONLY products.catalogo_productos
ADD CONSTRAINT fk_catalogo_productos_productos FOREIGN KEY (id_producto) REFERENCES products.productos(id_producto);
--
-- TOC entry 4781 (class 2606 OID 16859)
-- Name: caracteristica fk_caracteristica_servicio; Type: FK CONSTRAINT; Schema: services; Owner: ebroot
--
ALTER TABLE ONLY services.caracteristica
ADD CONSTRAINT fk_caracteristica_servicio FOREIGN KEY (id_servicio) REFERENCES services.servicio(id_servicio) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- TOC entry 4782 (class 2606 OID 16864)
-- Name: componente fk_componente_servicio; Type: FK CONSTRAINT; Schema: services; Owner: ebroot
--
ALTER TABLE ONLY services.componente
ADD CONSTRAINT fk_componente_servicio FOREIGN KEY (id_servicio) REFERENCES services.servicio(id_servicio) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- TOC entry 4790 (class 2606 OID 16854)
-- Name: servicio fk_servicio_empresa; Type: FK CONSTRAINT; Schema: services; Owner: ebroot
--
ALTER TABLE ONLY services.servicio
ADD CONSTRAINT fk_servicio_empresa FOREIGN KEY (id_empresa) REFERENCES base.empresa(id_empresa) ON UPDATE RESTRICT ON DELETE RESTRICT;
-- Completed on 2024-08-26 18:11:04
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,119 @@
-- Downloaded from: https://github.com/Timovski/Co-opMinesweeper/blob/c5db38d9c758b7121c0fc01e0bfedead718e709c/db.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.1
-- Dumped by pg_dump version 11.1
-- Started on 2019-02-20 21:09:05
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 client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 198 (class 1255 OID 16458)
-- Name: create_game(character varying); Type: PROCEDURE; Schema: public; Owner: postgres
--
CREATE PROCEDURE public.create_game(INOUT new_host_connection_id character varying)
LANGUAGE sql
AS $$
WITH new_game_id_holder (new_game_id) AS (
SELECT n.random_number
FROM (
SELECT LPAD(FLOOR(random() * 10000)::varchar, 4, '0') AS random_number
FROM generate_series(1, (SELECT COUNT(*) FROM public.games) + 10)
) AS n
LEFT OUTER JOIN
public.games AS g on g.game_id = n.random_number
WHERE g.id IS NULL
LIMIT 1
)
INSERT INTO public.games (
game_id,
host_connection_id
)
VALUES (
(SELECT new_game_id FROM new_game_id_holder),
new_host_connection_id
)
RETURNING game_id;
$$;
ALTER PROCEDURE public.create_game(INOUT new_host_connection_id character varying) OWNER TO postgres;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 196 (class 1259 OID 16449)
-- Name: games; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.games (
id bigint NOT NULL,
game_id character varying(4) NOT NULL,
host_connection_id character varying(50) NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.games OWNER TO postgres;
--
-- TOC entry 197 (class 1259 OID 16453)
-- Name: games_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.games_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.games_id_seq OWNER TO postgres;
--
-- TOC entry 2816 (class 0 OID 0)
-- Dependencies: 197
-- Name: games_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.games_id_seq OWNED BY public.games.id;
--
-- TOC entry 2687 (class 2604 OID 16455)
-- Name: games id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.games ALTER COLUMN id SET DEFAULT nextval('public.games_id_seq'::regclass);
--
-- TOC entry 2689 (class 2606 OID 16457)
-- Name: games games_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.games
ADD CONSTRAINT games_pkey PRIMARY KEY (id);
-- Completed on 2019-02-20 21:09:05
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,396 @@
-- Downloaded from: https://github.com/Vinicius02612/sistema_da_associacao/blob/119156f1a695cb012e6c9c5806ef1266adb48036/Backend/Arq_bd/BASE_DIR.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.4
-- Dumped by pg_dump version 16.4
-- Started on 2024-11-10 23:49:46
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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 217 (class 1259 OID 16444)
-- Name: administrador; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.administrador (
id integer NOT NULL,
nome character(30) NOT NULL
);
ALTER TABLE public.administrador OWNER TO postgres;
--
-- TOC entry 221 (class 1259 OID 16474)
-- Name: despesa; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.despesa (
id integer NOT NULL,
data date NOT NULL,
valor double precision NOT NULL,
origem character varying(100)
);
ALTER TABLE public.despesa OWNER TO postgres;
--
-- TOC entry 220 (class 1259 OID 16464)
-- Name: mensalidade; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.mensalidade (
id integer NOT NULL,
titulo character varying(100),
datavalidade date,
datareferencia date,
valor double precision NOT NULL,
status boolean NOT NULL,
socio_id integer
);
ALTER TABLE public.mensalidade OWNER TO postgres;
--
-- TOC entry 219 (class 1259 OID 16459)
-- Name: projeto; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.projeto (
id integer NOT NULL,
titulo character varying(100) NOT NULL,
datainicio date NOT NULL,
datafim date,
status character varying(50),
nomeorganizacao character varying(100)
);
ALTER TABLE public.projeto OWNER TO postgres;
--
-- TOC entry 222 (class 1259 OID 16479)
-- Name: receita; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.receita (
id integer NOT NULL,
data date NOT NULL,
valor double precision NOT NULL,
origem character varying(100)
);
ALTER TABLE public.receita OWNER TO postgres;
--
-- TOC entry 223 (class 1259 OID 16484)
-- Name: relatorio; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.relatorio (
id integer NOT NULL,
titulo character varying(100) NOT NULL,
datacriacao date,
receita_id integer,
despesa_id integer
);
ALTER TABLE public.relatorio OWNER TO postgres;
--
-- TOC entry 216 (class 1259 OID 16434)
-- Name: socio; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.socio (
id integer NOT NULL,
statuspagamento boolean,
cargo character varying(100)
);
ALTER TABLE public.socio OWNER TO postgres;
--
-- TOC entry 218 (class 1259 OID 16454)
-- Name: solicitacao; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.solicitacao (
id integer NOT NULL,
status boolean NOT NULL
);
ALTER TABLE public.solicitacao OWNER TO postgres;
--
-- TOC entry 215 (class 1259 OID 16427)
-- Name: usuario; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.usuario (
id integer NOT NULL,
nome character varying(100) NOT NULL,
cpf character varying(14) NOT NULL,
email character varying(100) NOT NULL,
senha character varying(100) NOT NULL,
tipousuario character varying(50) NOT NULL,
datanascimento date,
quantidadepessoasfamilia integer
);
ALTER TABLE public.usuario OWNER TO postgres;
--
-- TOC entry 4835 (class 0 OID 16444)
-- Dependencies: 217
-- Data for Name: administrador; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.administrador (id, nome) FROM stdin;
\.
--
-- TOC entry 4839 (class 0 OID 16474)
-- Dependencies: 221
-- Data for Name: despesa; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.despesa (id, data, valor, origem) FROM stdin;
\.
--
-- TOC entry 4838 (class 0 OID 16464)
-- Dependencies: 220
-- Data for Name: mensalidade; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.mensalidade (id, titulo, datavalidade, datareferencia, valor, status, socio_id) FROM stdin;
\.
--
-- TOC entry 4837 (class 0 OID 16459)
-- Dependencies: 219
-- Data for Name: projeto; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.projeto (id, titulo, datainicio, datafim, status, nomeorganizacao) FROM stdin;
\.
--
-- TOC entry 4840 (class 0 OID 16479)
-- Dependencies: 222
-- Data for Name: receita; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.receita (id, data, valor, origem) FROM stdin;
\.
--
-- TOC entry 4841 (class 0 OID 16484)
-- Dependencies: 223
-- Data for Name: relatorio; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.relatorio (id, titulo, datacriacao, receita_id, despesa_id) FROM stdin;
\.
--
-- TOC entry 4834 (class 0 OID 16434)
-- Dependencies: 216
-- Data for Name: socio; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.socio (id, statuspagamento, cargo) FROM stdin;
\.
--
-- TOC entry 4836 (class 0 OID 16454)
-- Dependencies: 218
-- Data for Name: solicitacao; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.solicitacao (id, status) FROM stdin;
\.
--
-- TOC entry 4833 (class 0 OID 16427)
-- Dependencies: 215
-- Data for Name: usuario; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.usuario (id, nome, cpf, email, senha, tipousuario, datanascimento, quantidadepessoasfamilia) FROM stdin;
\.
--
-- TOC entry 4672 (class 2606 OID 16448)
-- Name: administrador administrador_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.administrador
ADD CONSTRAINT administrador_pkey PRIMARY KEY (id);
--
-- TOC entry 4680 (class 2606 OID 16478)
-- Name: despesa despesa_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.despesa
ADD CONSTRAINT despesa_pkey PRIMARY KEY (id);
--
-- TOC entry 4678 (class 2606 OID 16468)
-- Name: mensalidade mensalidade_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.mensalidade
ADD CONSTRAINT mensalidade_pkey PRIMARY KEY (id);
--
-- TOC entry 4676 (class 2606 OID 16463)
-- Name: projeto projeto_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.projeto
ADD CONSTRAINT projeto_pkey PRIMARY KEY (id);
--
-- TOC entry 4682 (class 2606 OID 16483)
-- Name: receita receita_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.receita
ADD CONSTRAINT receita_pkey PRIMARY KEY (id);
--
-- TOC entry 4684 (class 2606 OID 16488)
-- Name: relatorio relatorio_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.relatorio
ADD CONSTRAINT relatorio_pkey PRIMARY KEY (id);
--
-- TOC entry 4670 (class 2606 OID 16438)
-- Name: socio socio_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.socio
ADD CONSTRAINT socio_pkey PRIMARY KEY (id);
--
-- TOC entry 4674 (class 2606 OID 16458)
-- Name: solicitacao solicitacao_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.solicitacao
ADD CONSTRAINT solicitacao_pkey PRIMARY KEY (id);
--
-- TOC entry 4666 (class 2606 OID 16433)
-- Name: usuario usuario_cpf_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.usuario
ADD CONSTRAINT usuario_cpf_key UNIQUE (cpf);
--
-- TOC entry 4668 (class 2606 OID 16431)
-- Name: usuario usuario_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.usuario
ADD CONSTRAINT usuario_pkey PRIMARY KEY (id);
--
-- TOC entry 4686 (class 2606 OID 16449)
-- Name: administrador administrador_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.administrador
ADD CONSTRAINT administrador_id_fkey FOREIGN KEY (id) REFERENCES public.usuario(id);
--
-- TOC entry 4687 (class 2606 OID 16469)
-- Name: mensalidade mensalidade_socio_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.mensalidade
ADD CONSTRAINT mensalidade_socio_id_fkey FOREIGN KEY (socio_id) REFERENCES public.socio(id);
--
-- TOC entry 4688 (class 2606 OID 16494)
-- Name: relatorio relatorio_despesa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.relatorio
ADD CONSTRAINT relatorio_despesa_id_fkey FOREIGN KEY (despesa_id) REFERENCES public.despesa(id);
--
-- TOC entry 4689 (class 2606 OID 16489)
-- Name: relatorio relatorio_receita_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.relatorio
ADD CONSTRAINT relatorio_receita_id_fkey FOREIGN KEY (receita_id) REFERENCES public.receita(id);
--
-- TOC entry 4685 (class 2606 OID 16439)
-- Name: socio socio_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.socio
ADD CONSTRAINT socio_id_fkey FOREIGN KEY (id) REFERENCES public.usuario(id);
-- Completed on 2024-11-10 23:49:46
--
-- PostgreSQL database dump complete
--
+940
View File
@@ -0,0 +1,940 @@
-- Downloaded from: https://github.com/WhoIsKatie/e-Hotels/blob/83bbd189f6f8ee312e8fca8830e33ae67b18558b/server/database.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 15.2
-- Dumped by pg_dump version 15.2
-- Started on 2023-03-31 21:08:48
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;
--
-- TOC entry 3475 (class 1262 OID 16899)
-- Name: e-Hotels; Type: DATABASE; Schema: -; Owner: postgres
--
CREATE DATABASE "e-Hotels" WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'English_United States.1252';
ALTER DATABASE "e-Hotels" OWNER TO postgres;
\connect -reuse-previous=on "dbname='e-Hotels'"
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;
--
-- TOC entry 238 (class 1255 OID 17123)
-- Name: employee_is_manager(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.employee_is_manager() RETURNS trigger
LANGUAGE plpgsql
AS $$BEGIN
IF NOT EXISTS (select * FROM inst_role WHERE (role_sin = NEW.manager_id
AND role_name = 'manager'))
THEN ROLLBACK;
END IF;
RETURN NULL;
END;$$;
ALTER FUNCTION public.employee_is_manager() OWNER TO postgres;
--
-- TOC entry 239 (class 1255 OID 17350)
-- Name: employee_not_customer_or_same_hotel(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.employee_not_customer_or_same_hotel() RETURNS trigger
LANGUAGE plpgsql
AS $$BEGIN
IF EXISTS (SELECT * FROM booking WHERE (booking_id = NEW.booking_id
AND customer_sin = NEW.employee_sin))
THEN ROLLBACK;
ELSE
IF NOT EXISTS (SELECT * FROM booking AS b, employee AS e
WHERE (b.booking_id = NEW.booking_id
AND b.hotel_id = e.hotel_id))
THEN ROLLBACK;
END IF;
END IF;
RETURN NULL;
END;$$;
ALTER FUNCTION public.employee_not_customer_or_same_hotel() OWNER TO postgres;
--
-- TOC entry 221 (class 1259 OID 16925)
-- Name: chain_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.chain_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.chain_id_seq OWNER TO postgres;
--
-- TOC entry 235 (class 1259 OID 17127)
-- Name: hotel_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.hotel_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.hotel_id_seq OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 219 (class 1259 OID 16918)
-- Name: hotel; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.hotel (
hotel_id integer DEFAULT nextval('public.hotel_id_seq'::regclass) NOT NULL,
chain_id integer NOT NULL,
street_num integer NOT NULL,
street_name character varying(100) NOT NULL,
unit_num integer,
city character varying(100) NOT NULL,
state character varying(2) NOT NULL,
country character varying(30) NOT NULL,
postal_code character varying(10) NOT NULL,
rating integer NOT NULL,
manager_id numeric(9,0) NOT NULL,
email character varying(100) NOT NULL,
CONSTRAINT hotel_rating_check CHECK (((rating >= 1) AND (rating <= 5)))
);
ALTER TABLE public.hotel OWNER TO postgres;
--
-- TOC entry 220 (class 1259 OID 16922)
-- Name: hotel_chain; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.hotel_chain (
chain_id integer DEFAULT nextval('public.chain_id_seq'::regclass) NOT NULL,
name character varying(50) NOT NULL,
street_num integer NOT NULL,
street_name character varying(100) NOT NULL,
unit_num integer,
city character varying(20) NOT NULL,
state character(2),
country character varying(30),
postal_code character varying(10)
);
ALTER TABLE public.hotel_chain OWNER TO postgres;
--
-- TOC entry 233 (class 1259 OID 16959)
-- Name: room; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.room (
room_number integer NOT NULL,
price money,
capacity integer,
max_capacity integer,
hotel_id integer NOT NULL,
CONSTRAINT room_check CHECK (((capacity >= 1) AND (max_capacity >= capacity))),
CONSTRAINT room_number_check CHECK ((room_number >= 0))
);
ALTER TABLE public.room OWNER TO postgres;
--
-- TOC entry 237 (class 1259 OID 17371)
-- Name: available_rooms; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW public.available_rooms AS
SELECT room.room_number,
room.price,
room.capacity,
room.max_capacity,
hotel.hotel_id,
hotel.city,
hotel.state,
hotel.country,
hotel.rating,
hotel_chain.name AS chain_name
FROM ((public.room
JOIN public.hotel ON ((room.hotel_id = hotel.hotel_id)))
JOIN public.hotel_chain ON ((hotel.chain_id = hotel_chain.chain_id)));
ALTER TABLE public.available_rooms OWNER TO postgres;
--
-- TOC entry 214 (class 1259 OID 16900)
-- Name: booking; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.booking (
booking_id bigint NOT NULL,
checkin_date date NOT NULL,
checkout_date date NOT NULL,
hotel_id integer NOT NULL,
customer_sin numeric(9,0) NOT NULL,
room_number integer NOT NULL,
CONSTRAINT valid_dates CHECK ((checkout_date > checkin_date))
);
ALTER TABLE public.booking OWNER TO postgres;
--
-- TOC entry 215 (class 1259 OID 16903)
-- Name: booking_booking_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.booking_booking_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.booking_booking_id_seq OWNER TO postgres;
--
-- TOC entry 3476 (class 0 OID 0)
-- Dependencies: 215
-- Name: booking_booking_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.booking_booking_id_seq OWNED BY public.booking.booking_id;
--
-- TOC entry 217 (class 1259 OID 16910)
-- Name: chain_inst_phone_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.chain_inst_phone_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.chain_inst_phone_id_seq OWNER TO postgres;
--
-- TOC entry 230 (class 1259 OID 16952)
-- Name: customer; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.customer (
customer_sin numeric(9,0) NOT NULL,
registration_date date NOT NULL
);
ALTER TABLE public.customer OWNER TO postgres;
--
-- TOC entry 218 (class 1259 OID 16914)
-- Name: employee; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.employee (
sin numeric(9,0) NOT NULL,
hotel_id integer NOT NULL,
salary money NOT NULL
);
ALTER TABLE public.employee OWNER TO postgres;
--
-- TOC entry 236 (class 1259 OID 17366)
-- Name: hotel_capacity; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW public.hotel_capacity AS
SELECT room.capacity,
room.max_capacity,
hotel.hotel_id
FROM (public.room
JOIN public.hotel ON ((room.hotel_id = hotel.hotel_id)));
ALTER TABLE public.hotel_capacity OWNER TO postgres;
--
-- TOC entry 223 (class 1259 OID 16929)
-- Name: inst_amenity; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.inst_amenity (
amenity_id integer NOT NULL,
amenity character varying(100) NOT NULL,
hotel_id integer NOT NULL
);
ALTER TABLE public.inst_amenity OWNER TO postgres;
--
-- TOC entry 216 (class 1259 OID 16907)
-- Name: inst_chain_phone; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.inst_chain_phone (
chain_phone_id integer DEFAULT nextval('public.chain_inst_phone_id_seq'::regclass) NOT NULL,
phone_number numeric(10,0) NOT NULL
);
ALTER TABLE public.inst_chain_phone OWNER TO postgres;
--
-- TOC entry 224 (class 1259 OID 16932)
-- Name: inst_concern; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.inst_concern (
concern_id integer NOT NULL,
concern character varying(200) NOT NULL,
hotel_id integer NOT NULL
);
ALTER TABLE public.inst_concern OWNER TO postgres;
--
-- TOC entry 226 (class 1259 OID 16938)
-- Name: inst_email_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.inst_email_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.inst_email_id_seq OWNER TO postgres;
--
-- TOC entry 225 (class 1259 OID 16935)
-- Name: inst_email; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.inst_email (
email_id integer DEFAULT nextval('public.inst_email_id_seq'::regclass) NOT NULL,
email character varying(100) NOT NULL
);
ALTER TABLE public.inst_email OWNER TO postgres;
--
-- TOC entry 222 (class 1259 OID 16926)
-- Name: inst_hotel_phone; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.inst_hotel_phone (
phone_id integer NOT NULL,
phone_number numeric(10,0) NOT NULL
);
ALTER TABLE public.inst_hotel_phone OWNER TO postgres;
--
-- TOC entry 227 (class 1259 OID 16939)
-- Name: inst_role; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.inst_role (
role_sin numeric(9,0) NOT NULL,
role_name character varying(80) NOT NULL
);
ALTER TABLE public.inst_role OWNER TO postgres;
--
-- TOC entry 228 (class 1259 OID 16942)
-- Name: manages; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.manages (
booking_id bigint NOT NULL,
employee_sin numeric(9,0) NOT NULL
);
ALTER TABLE public.manages OWNER TO postgres;
--
-- TOC entry 229 (class 1259 OID 16945)
-- Name: person; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.person (
sin numeric(9,0) NOT NULL,
first_name character varying,
last_name character varying,
middle_name character varying,
street_num integer,
street_name character varying,
unit_num integer,
city character varying,
state character varying(2),
country character varying(20),
postal_code character varying(10),
CONSTRAINT person_street_num_check CHECK ((street_num > 0))
);
ALTER TABLE public.person OWNER TO postgres;
--
-- TOC entry 231 (class 1259 OID 16955)
-- Name: renting; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.renting (
booking_id bigint NOT NULL,
cc_number numeric(16,0) NOT NULL,
expiry_date date NOT NULL
);
ALTER TABLE public.renting OWNER TO postgres;
--
-- TOC entry 232 (class 1259 OID 16958)
-- Name: renting_booking_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.renting_booking_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.renting_booking_id_seq OWNER TO postgres;
--
-- TOC entry 3477 (class 0 OID 0)
-- Dependencies: 232
-- Name: renting_booking_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.renting_booking_id_seq OWNED BY public.renting.booking_id;
--
-- TOC entry 234 (class 1259 OID 16964)
-- Name: supervises; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.supervises (
subordinate_sin numeric(9,0) NOT NULL,
supervisor_sin numeric(9,0) NOT NULL
);
ALTER TABLE public.supervises OWNER TO postgres;
--
-- TOC entry 3248 (class 2604 OID 16967)
-- Name: booking booking_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.booking ALTER COLUMN booking_id SET DEFAULT nextval('public.booking_booking_id_seq'::regclass);
--
-- TOC entry 3253 (class 2604 OID 16971)
-- Name: renting booking_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.renting ALTER COLUMN booking_id SET DEFAULT nextval('public.renting_booking_id_seq'::regclass);
--
-- TOC entry 3263 (class 2606 OID 16973)
-- Name: booking booking_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.booking
ADD CONSTRAINT booking_pkey PRIMARY KEY (booking_id);
--
-- TOC entry 3266 (class 2606 OID 16977)
-- Name: inst_chain_phone chain_inst_phone_number_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_chain_phone
ADD CONSTRAINT chain_inst_phone_number_key UNIQUE (phone_number);
--
-- TOC entry 3268 (class 2606 OID 16979)
-- Name: inst_chain_phone chain_inst_phone_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_chain_phone
ADD CONSTRAINT chain_inst_phone_pkey PRIMARY KEY (chain_phone_id, phone_number);
--
-- TOC entry 3298 (class 2606 OID 17356)
-- Name: customer customer_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.customer
ADD CONSTRAINT customer_pkey PRIMARY KEY (customer_sin);
--
-- TOC entry 3270 (class 2606 OID 16983)
-- Name: employee employee_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.employee
ADD CONSTRAINT employee_pkey PRIMARY KEY (sin);
--
-- TOC entry 3280 (class 2606 OID 16985)
-- Name: hotel_chain hotel_chain_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hotel_chain
ADD CONSTRAINT hotel_chain_pkey PRIMARY KEY (chain_id);
--
-- TOC entry 3282 (class 2606 OID 16987)
-- Name: inst_hotel_phone hotel_inst_phone_number_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_hotel_phone
ADD CONSTRAINT hotel_inst_phone_number_key UNIQUE (phone_number);
--
-- TOC entry 3275 (class 2606 OID 17121)
-- Name: hotel hotel_manager_unique; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hotel
ADD CONSTRAINT hotel_manager_unique UNIQUE (manager_id);
--
-- TOC entry 3277 (class 2606 OID 17201)
-- Name: hotel hotel_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hotel
ADD CONSTRAINT hotel_pkey PRIMARY KEY (hotel_id);
--
-- TOC entry 3284 (class 2606 OID 16991)
-- Name: inst_amenity inst_amenity_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_amenity
ADD CONSTRAINT inst_amenity_pkey PRIMARY KEY (amenity_id, amenity);
--
-- TOC entry 3286 (class 2606 OID 17132)
-- Name: inst_concern inst_concern_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_concern
ADD CONSTRAINT inst_concern_pkey PRIMARY KEY (concern_id, concern);
--
-- TOC entry 3288 (class 2606 OID 16995)
-- Name: inst_email inst_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_email
ADD CONSTRAINT inst_email_key UNIQUE (email);
--
-- TOC entry 3290 (class 2606 OID 16997)
-- Name: inst_email inst_email_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_email
ADD CONSTRAINT inst_email_pkey PRIMARY KEY (email_id, email);
--
-- TOC entry 3292 (class 2606 OID 17130)
-- Name: inst_role inst_role_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_role
ADD CONSTRAINT inst_role_pkey PRIMARY KEY (role_sin, role_name);
--
-- TOC entry 3294 (class 2606 OID 17307)
-- Name: manages manages_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.manages
ADD CONSTRAINT manages_pkey PRIMARY KEY (booking_id);
--
-- TOC entry 3296 (class 2606 OID 17003)
-- Name: person person_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.person
ADD CONSTRAINT person_pkey PRIMARY KEY (sin);
--
-- TOC entry 3300 (class 2606 OID 17309)
-- Name: renting renting_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.renting
ADD CONSTRAINT renting_pkey PRIMARY KEY (booking_id, cc_number, expiry_date);
--
-- TOC entry 3303 (class 2606 OID 17242)
-- Name: room room_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.room
ADD CONSTRAINT room_pkey PRIMARY KEY (room_number, hotel_id);
--
-- TOC entry 3259 (class 1259 OID 17346)
-- Name: booking_checkin_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX booking_checkin_index ON public.booking USING btree (checkin_date);
--
-- TOC entry 3260 (class 1259 OID 17347)
-- Name: booking_checkout_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX booking_checkout_index ON public.booking USING btree (checkout_date);
--
-- TOC entry 3261 (class 1259 OID 17345)
-- Name: booking_customer_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX booking_customer_index ON public.booking USING btree (customer_sin);
--
-- TOC entry 3264 (class 1259 OID 17348)
-- Name: booking_room_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX booking_room_index ON public.booking USING btree (room_number);
--
-- TOC entry 3271 (class 1259 OID 17294)
-- Name: hotel_chain_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX hotel_chain_index ON public.hotel USING btree (chain_id);
--
-- TOC entry 3272 (class 1259 OID 17295)
-- Name: hotel_city_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX hotel_city_index ON public.hotel USING btree (city);
--
-- TOC entry 3273 (class 1259 OID 17296)
-- Name: hotel_country_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX hotel_country_index ON public.hotel USING btree (country);
--
-- TOC entry 3278 (class 1259 OID 17297)
-- Name: hotel_rating_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX hotel_rating_index ON public.hotel USING btree (rating);
--
-- TOC entry 3301 (class 1259 OID 17293)
-- Name: room_capacity_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX room_capacity_index ON public.room USING btree (max_capacity);
--
-- TOC entry 3304 (class 1259 OID 17298)
-- Name: room_price_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX room_price_index ON public.room USING btree (price);
--
-- TOC entry 3324 (class 2620 OID 17134)
-- Name: hotel hotel_manager_constraint_trigger; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE CONSTRAINT TRIGGER hotel_manager_constraint_trigger AFTER INSERT OR UPDATE ON public.hotel DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION public.employee_is_manager();
--
-- TOC entry 3325 (class 2620 OID 17353)
-- Name: manages managing_employee_constraint_trigger; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE CONSTRAINT TRIGGER managing_employee_constraint_trigger AFTER INSERT OR UPDATE ON public.manages NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION public.employee_not_customer_or_same_hotel();
--
-- TOC entry 3305 (class 2606 OID 17357)
-- Name: booking booking_customer_sin_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.booking
ADD CONSTRAINT booking_customer_sin_fkey FOREIGN KEY (customer_sin) REFERENCES public.customer(customer_sin);
--
-- TOC entry 3306 (class 2606 OID 17325)
-- Name: booking booking_hotel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.booking
ADD CONSTRAINT booking_hotel_id_fkey FOREIGN KEY (hotel_id) REFERENCES public.hotel(hotel_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3307 (class 2606 OID 17340)
-- Name: booking booking_hotel_id_room_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.booking
ADD CONSTRAINT booking_hotel_id_room_number_fkey FOREIGN KEY (hotel_id, room_number) REFERENCES public.room(hotel_id, room_number) ON UPDATE CASCADE;
--
-- TOC entry 3308 (class 2606 OID 17030)
-- Name: inst_chain_phone chain_inst_phone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_chain_phone
ADD CONSTRAINT chain_inst_phone_id_fkey FOREIGN KEY (chain_phone_id) REFERENCES public.hotel_chain(chain_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3319 (class 2606 OID 17310)
-- Name: customer customer_sin_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.customer
ADD CONSTRAINT customer_sin_fkey FOREIGN KEY (customer_sin) REFERENCES public.person(sin) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3309 (class 2606 OID 17258)
-- Name: employee employee_hotel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.employee
ADD CONSTRAINT employee_hotel_id_fkey FOREIGN KEY (hotel_id) REFERENCES public.hotel(hotel_id) DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3310 (class 2606 OID 17045)
-- Name: employee employee_sin_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.employee
ADD CONSTRAINT employee_sin_fkey FOREIGN KEY (sin) REFERENCES public.person(sin) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3311 (class 2606 OID 17050)
-- Name: hotel hotel_chain_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hotel
ADD CONSTRAINT hotel_chain_id_fkey FOREIGN KEY (chain_id) REFERENCES public.hotel_chain(chain_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3313 (class 2606 OID 17273)
-- Name: inst_hotel_phone hotel_inst_phone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_hotel_phone
ADD CONSTRAINT hotel_inst_phone_id_fkey FOREIGN KEY (phone_id) REFERENCES public.hotel(hotel_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3314 (class 2606 OID 17263)
-- Name: inst_amenity inst_amenity_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_amenity
ADD CONSTRAINT inst_amenity_id_fkey FOREIGN KEY (amenity_id, hotel_id) REFERENCES public.room(room_number, hotel_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3315 (class 2606 OID 17268)
-- Name: inst_concern inst_concern_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_concern
ADD CONSTRAINT inst_concern_id_fkey FOREIGN KEY (concern_id, hotel_id) REFERENCES public.room(room_number, hotel_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3316 (class 2606 OID 17070)
-- Name: inst_email inst_email_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_email
ADD CONSTRAINT inst_email_id_fkey FOREIGN KEY (email_id) REFERENCES public.hotel_chain(chain_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3317 (class 2606 OID 17075)
-- Name: inst_role inst_role_sin_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.inst_role
ADD CONSTRAINT inst_role_sin_fkey FOREIGN KEY (role_sin) REFERENCES public.employee(sin) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3312 (class 2606 OID 17080)
-- Name: hotel manager_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.hotel
ADD CONSTRAINT manager_id_fkey FOREIGN KEY (manager_id) REFERENCES public.employee(sin) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED;
--
-- TOC entry 3318 (class 2606 OID 17090)
-- Name: manages manages_employee_sin_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.manages
ADD CONSTRAINT manages_employee_sin_fkey FOREIGN KEY (employee_sin) REFERENCES public.employee(sin) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 3320 (class 2606 OID 17105)
-- Name: renting renting_booking_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.renting
ADD CONSTRAINT renting_booking_id_fkey FOREIGN KEY (booking_id) REFERENCES public.booking(booking_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3321 (class 2606 OID 17288)
-- Name: room room_hotel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.room
ADD CONSTRAINT room_hotel_id_fkey FOREIGN KEY (hotel_id) REFERENCES public.hotel(hotel_id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3322 (class 2606 OID 17110)
-- Name: supervises supervises_subordinate_sin_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.supervises
ADD CONSTRAINT supervises_subordinate_sin_fkey FOREIGN KEY (subordinate_sin) REFERENCES public.employee(sin) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 3323 (class 2606 OID 17115)
-- Name: supervises supervises_supervisor_sin_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.supervises
ADD CONSTRAINT supervises_supervisor_sin_fkey FOREIGN KEY (supervisor_sin) REFERENCES public.employee(sin) ON UPDATE CASCADE ON DELETE CASCADE;
-- Completed on 2023-03-31 21:08:49
--
-- PostgreSQL database dump complete
--
+419
View File
@@ -0,0 +1,419 @@
-- Downloaded from: https://github.com/Xarpunk/DemExam/blob/3a08536412872ed8495b1d529cadbd1dc1bb004a/dem_backup.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 17.4
-- Dumped by pg_dump version 17.4
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;
--
-- Name: update_timestamp(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.update_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$;
ALTER FUNCTION public.update_timestamp() OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: material_receipts; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.material_receipts (
receipt_id integer NOT NULL,
material_id integer NOT NULL,
quantity numeric(10,2) NOT NULL,
receipt_date date NOT NULL,
unit_price numeric(10,2) NOT NULL,
supplier_id integer NOT NULL,
invoice_number character varying(50),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.material_receipts OWNER TO postgres;
--
-- Name: material_receipts_receipt_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.material_receipts_receipt_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.material_receipts_receipt_id_seq OWNER TO postgres;
--
-- Name: material_receipts_receipt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.material_receipts_receipt_id_seq OWNED BY public.material_receipts.receipt_id;
--
-- Name: material_usage; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.material_usage (
usage_id integer NOT NULL,
material_id integer NOT NULL,
quantity numeric(10,2) NOT NULL,
usage_date date NOT NULL,
production_id integer,
notes text,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.material_usage OWNER TO postgres;
--
-- Name: material_usage_usage_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.material_usage_usage_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.material_usage_usage_id_seq OWNER TO postgres;
--
-- Name: material_usage_usage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.material_usage_usage_id_seq OWNED BY public.material_usage.usage_id;
--
-- Name: materials; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.materials (
material_id integer NOT NULL,
material_name character varying(100) NOT NULL,
description text,
unit_of_measure character varying(20) NOT NULL,
current_quantity numeric(10,2) DEFAULT 0 NOT NULL,
min_quantity numeric(10,2) DEFAULT 0 NOT NULL,
supplier_id integer,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.materials OWNER TO postgres;
--
-- Name: materials_material_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.materials_material_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.materials_material_id_seq OWNER TO postgres;
--
-- Name: materials_material_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.materials_material_id_seq OWNED BY public.materials.material_id;
--
-- Name: suppliers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.suppliers (
supplier_id integer NOT NULL,
supplier_name character varying(100) NOT NULL,
contact_person character varying(100),
phone character varying(20),
email character varying(100),
address text,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.suppliers OWNER TO postgres;
--
-- Name: suppliers_supplier_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.suppliers_supplier_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.suppliers_supplier_id_seq OWNER TO postgres;
--
-- Name: suppliers_supplier_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.suppliers_supplier_id_seq OWNED BY public.suppliers.supplier_id;
--
-- Name: material_receipts receipt_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.material_receipts ALTER COLUMN receipt_id SET DEFAULT nextval('public.material_receipts_receipt_id_seq'::regclass);
--
-- Name: material_usage usage_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.material_usage ALTER COLUMN usage_id SET DEFAULT nextval('public.material_usage_usage_id_seq'::regclass);
--
-- Name: materials material_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.materials ALTER COLUMN material_id SET DEFAULT nextval('public.materials_material_id_seq'::regclass);
--
-- Name: suppliers supplier_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.suppliers ALTER COLUMN supplier_id SET DEFAULT nextval('public.suppliers_supplier_id_seq'::regclass);
--
-- Data for Name: material_receipts; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.material_receipts (receipt_id, material_id, quantity, receipt_date, unit_price, supplier_id, invoice_number, created_at) FROM stdin;
2 2 500.00 2023-05-12 320.75 1 INV-2023-002 2025-06-17 00:00:00+03
3 3 300.00 2023-05-15 180.00 2 INV-2023-003 2025-06-17 00:00:00+03
4 4 50.00 2023-05-18 1200.00 3 INV-2023-004 2025-06-17 00:00:00+03
5 5 30.00 2023-05-20 450.00 2 INV-2023-005 2025-06-17 00:00:00+03
11 11 100.00 2025-06-16 500.00 1 \N 2025-06-17 00:00:00+03
\.
--
-- Data for Name: material_usage; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.material_usage (usage_id, material_id, quantity, usage_date, production_id, notes, created_at) FROM stdin;
2 2 120.50 2023-05-13 1002 Izgotovlenie detaley 2025-06-17 00:00:00+03
3 3 75.25 2023-05-16 1003 Litye komponentov 2025-06-17 00:00:00+03
4 4 10.00 2023-05-19 1004 Sborka upakovki 2025-06-17 00:00:00+03
5 5 5.00 2023-05-21 1005 Pokraska izdeliy 2025-06-17 00:00:00+03
\.
--
-- Data for Name: materials; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.materials (material_id, material_name, description, unit_of_measure, current_quantity, min_quantity, supplier_id, created_at, updated_at) FROM stdin;
2 Stal nerzhaveyushaya Listy 3mm, marka 304 kg 1200.50 300.00 1 2025-06-17 00:00:00+03 2025-06-17 00:00:00+03
3 Polipropilen Granuly dlya litya kg 750.25 200.00 2 2025-06-17 00:00:00+03 2025-06-17 00:00:00+03
4 Fanera Fanera 10mm, sort A list 80.00 20.00 3 2025-06-17 00:00:00+03 2025-06-17 00:00:00+03
5 Kraska belaya Akrilovaya, matovaya sht 45.00 10.00 2 2025-06-17 00:00:00+03 2025-06-17 00:00:00+03
11 Block \N sht 100.00 0.00 1 2025-06-17 00:00:00+03 2025-06-17 00:00:00+03
\.
--
-- Data for Name: suppliers; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.suppliers (supplier_id, supplier_name, contact_person, phone, email, address, created_at, updated_at) FROM stdin;
1 OOO "MetallSnab" Ivanov Petr +79161234567 metal@example.com g. Moskva, ul. Metallurgov, 15 2025-06-17 00:00:00+03 2025-06-17 00:00:00+03
2 AO "HimProm" Sidorova Anna +79167654321 chem@example.com g. Sankt-Peterburg, pr. Himikov, 42 2025-06-17 00:00:00+03 2025-06-17 00:00:00+03
3 IP "Derevoobrabotka" Petrov Vasiliy +79031234567 wood@example.com g. Ekaterinburg, ul. Lesnaya, 7 2025-06-17 00:00:00+03 2025-06-17 00:00:00+03
\.
--
-- Name: material_receipts_receipt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.material_receipts_receipt_id_seq', 12, true);
--
-- Name: material_usage_usage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.material_usage_usage_id_seq', 5, true);
--
-- Name: materials_material_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.materials_material_id_seq', 42, true);
--
-- Name: suppliers_supplier_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.suppliers_supplier_id_seq', 3, true);
--
-- Name: material_receipts material_receipts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.material_receipts
ADD CONSTRAINT material_receipts_pkey PRIMARY KEY (receipt_id);
--
-- Name: material_usage material_usage_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.material_usage
ADD CONSTRAINT material_usage_pkey PRIMARY KEY (usage_id);
--
-- Name: materials materials_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.materials
ADD CONSTRAINT materials_pkey PRIMARY KEY (material_id);
--
-- Name: suppliers suppliers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.suppliers
ADD CONSTRAINT suppliers_pkey PRIMARY KEY (supplier_id);
--
-- Name: idx_materials_supplier; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_materials_supplier ON public.materials USING btree (supplier_id);
--
-- Name: idx_receipts_material; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_receipts_material ON public.material_receipts USING btree (material_id);
--
-- Name: idx_receipts_supplier; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_receipts_supplier ON public.material_receipts USING btree (supplier_id);
--
-- Name: idx_usage_material; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_usage_material ON public.material_usage USING btree (material_id);
--
-- Name: materials update_materials_timestamp; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER update_materials_timestamp BEFORE UPDATE ON public.materials FOR EACH ROW EXECUTE FUNCTION public.update_timestamp();
ALTER TABLE public.materials DISABLE TRIGGER update_materials_timestamp;
--
-- Name: suppliers update_suppliers_timestamp; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER update_suppliers_timestamp BEFORE UPDATE ON public.suppliers FOR EACH ROW EXECUTE FUNCTION public.update_timestamp();
ALTER TABLE public.suppliers DISABLE TRIGGER update_suppliers_timestamp;
--
-- Name: material_receipts material_receipts_material_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.material_receipts
ADD CONSTRAINT material_receipts_material_id_fkey FOREIGN KEY (material_id) REFERENCES public.materials(material_id);
--
-- Name: material_receipts material_receipts_supplier_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.material_receipts
ADD CONSTRAINT material_receipts_supplier_id_fkey FOREIGN KEY (supplier_id) REFERENCES public.suppliers(supplier_id);
--
-- Name: material_usage material_usage_material_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.material_usage
ADD CONSTRAINT material_usage_material_id_fkey FOREIGN KEY (material_id) REFERENCES public.materials(material_id);
--
-- Name: materials materials_supplier_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.materials
ADD CONSTRAINT materials_supplier_id_fkey FOREIGN KEY (supplier_id) REFERENCES public.suppliers(supplier_id);
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,526 @@
-- Downloaded from: https://github.com/Yesk0/KBTU_Database_24-25/blob/ad089a5cc4f6302d82136d7722a929548a3c0e76/Employee.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.4
-- Dumped by pg_dump version 16.4
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;
--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: pg_database_owner
--
COMMENT ON SCHEMA public IS 'Standard public schema';
--
-- Name: adminpack; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS adminpack WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION adminpack; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION adminpack IS 'administrative functions for PostgreSQL';
--
-- Name: mpaa_rating; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.mpaa_rating AS ENUM (
'G',
'PG',
'PG-13',
'R',
'NC-17'
);
ALTER TYPE public.mpaa_rating OWNER TO postgres;
--
-- Name: year; Type: DOMAIN; Schema: public; Owner: postgres
--
CREATE DOMAIN public.year AS integer
CONSTRAINT year_check CHECK (((VALUE >= 1901) AND (VALUE <= 2155)));
ALTER DOMAIN public.year OWNER TO postgres;
--
-- Name: _group_concat(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public._group_concat(text, text) RETURNS text
LANGUAGE sql IMMUTABLE
AS $_$
SELECT CASE
WHEN $2 IS NULL THEN $1
WHEN $1 IS NULL THEN $2
ELSE $1 || ', ' || $2
END
$_$;
ALTER FUNCTION public._group_concat(text, text) OWNER TO postgres;
--
-- Name: film_in_stock(integer, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.film_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) RETURNS SETOF integer
LANGUAGE sql
AS $_$
SELECT inventory_id
FROM inventory
WHERE film_id = $1
AND store_id = $2
AND inventory_in_stock(inventory_id);
$_$;
ALTER FUNCTION public.film_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) OWNER TO postgres;
--
-- Name: film_not_in_stock(integer, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.film_not_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) RETURNS SETOF integer
LANGUAGE sql
AS $_$
SELECT inventory_id
FROM inventory
WHERE film_id = $1
AND store_id = $2
AND NOT inventory_in_stock(inventory_id);
$_$;
ALTER FUNCTION public.film_not_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) OWNER TO postgres;
--
-- Name: get_customer_balance(integer, timestamp without time zone); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.get_customer_balance(p_customer_id integer, p_effective_date timestamp without time zone) RETURNS numeric
LANGUAGE plpgsql
AS $$
--#OK, WE NEED TO CALCULATE THE CURRENT BALANCE GIVEN A CUSTOMER_ID AND A DATE
--#THAT WE WANT THE BALANCE TO BE EFFECTIVE FOR. THE BALANCE IS:
--# 1) RENTAL FEES FOR ALL PREVIOUS RENTALS
--# 2) ONE DOLLAR FOR EVERY DAY THE PREVIOUS RENTALS ARE OVERDUE
--# 3) IF A FILM IS MORE THAN RENTAL_DURATION * 2 OVERDUE, CHARGE THE REPLACEMENT_COST
--# 4) SUBTRACT ALL PAYMENTS MADE BEFORE THE DATE SPECIFIED
DECLARE
v_rentfees DECIMAL(5,2); --#FEES PAID TO RENT THE VIDEOS INITIALLY
v_overfees INTEGER; --#LATE FEES FOR PRIOR RENTALS
v_payments DECIMAL(5,2); --#SUM OF PAYMENTS MADE PREVIOUSLY
BEGIN
SELECT COALESCE(SUM(film.rental_rate),0) INTO v_rentfees
FROM film, inventory, rental
WHERE film.film_id = inventory.film_id
AND inventory.inventory_id = rental.inventory_id
AND rental.rental_date <= p_effective_date
AND rental.customer_id = p_customer_id;
SELECT COALESCE(SUM(IF((rental.return_date - rental.rental_date) > (film.rental_duration * '1 day'::interval),
((rental.return_date - rental.rental_date) - (film.rental_duration * '1 day'::interval)),0)),0) INTO v_overfees
FROM rental, inventory, film
WHERE film.film_id = inventory.film_id
AND inventory.inventory_id = rental.inventory_id
AND rental.rental_date <= p_effective_date
AND rental.customer_id = p_customer_id;
SELECT COALESCE(SUM(payment.amount),0) INTO v_payments
FROM payment
WHERE payment.payment_date <= p_effective_date
AND payment.customer_id = p_customer_id;
RETURN v_rentfees + v_overfees - v_payments;
END
$$;
ALTER FUNCTION public.get_customer_balance(p_customer_id integer, p_effective_date timestamp without time zone) OWNER TO postgres;
--
-- Name: inventory_held_by_customer(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.inventory_held_by_customer(p_inventory_id integer) RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
v_customer_id INTEGER;
BEGIN
SELECT customer_id INTO v_customer_id
FROM rental
WHERE return_date IS NULL
AND inventory_id = p_inventory_id;
RETURN v_customer_id;
END $$;
ALTER FUNCTION public.inventory_held_by_customer(p_inventory_id integer) OWNER TO postgres;
--
-- Name: inventory_in_stock(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.inventory_in_stock(p_inventory_id integer) RETURNS boolean
LANGUAGE plpgsql
AS $$
DECLARE
v_rentals INTEGER;
v_out INTEGER;
BEGIN
-- AN ITEM IS IN-STOCK IF THERE ARE EITHER NO ROWS IN THE rental TABLE
-- FOR THE ITEM OR ALL ROWS HAVE return_date POPULATED
SELECT count(*) INTO v_rentals
FROM rental
WHERE inventory_id = p_inventory_id;
IF v_rentals = 0 THEN
RETURN TRUE;
END IF;
SELECT COUNT(rental_id) INTO v_out
FROM inventory LEFT JOIN rental USING(inventory_id)
WHERE inventory.inventory_id = p_inventory_id
AND rental.return_date IS NULL;
IF v_out > 0 THEN
RETURN FALSE;
ELSE
RETURN TRUE;
END IF;
END $$;
ALTER FUNCTION public.inventory_in_stock(p_inventory_id integer) OWNER TO postgres;
--
-- Name: last_day(timestamp without time zone); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.last_day(timestamp without time zone) RETURNS date
LANGUAGE sql IMMUTABLE STRICT
AS $_$
SELECT CASE
WHEN EXTRACT(MONTH FROM $1) = 12 THEN
(((EXTRACT(YEAR FROM $1) + 1) operator(pg_catalog.||) '-01-01')::date - INTERVAL '1 day')::date
ELSE
((EXTRACT(YEAR FROM $1) operator(pg_catalog.||) '-' operator(pg_catalog.||) (EXTRACT(MONTH FROM $1) + 1) operator(pg_catalog.||) '-01')::date - INTERVAL '1 day')::date
END
$_$;
ALTER FUNCTION public.last_day(timestamp without time zone) OWNER TO postgres;
--
-- Name: last_updated(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.last_updated() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.last_update = CURRENT_TIMESTAMP;
RETURN NEW;
END $$;
ALTER FUNCTION public.last_updated() OWNER TO postgres;
--
-- Name: group_concat(text); Type: AGGREGATE; Schema: public; Owner: postgres
--
CREATE AGGREGATE public.group_concat(text) (
SFUNC = public._group_concat,
STYPE = text
);
ALTER AGGREGATE public.group_concat(text) OWNER TO postgres;
--
-- Name: actor_actor_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.actor_actor_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.actor_actor_id_seq OWNER TO postgres;
--
-- Name: address_address_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.address_address_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.address_address_id_seq OWNER TO postgres;
--
-- Name: category_category_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.category_category_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.category_category_id_seq OWNER TO postgres;
--
-- Name: city_city_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.city_city_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.city_city_id_seq OWNER TO postgres;
--
-- Name: country_country_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.country_country_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.country_country_id_seq OWNER TO postgres;
--
-- Name: customer_customer_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.customer_customer_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.customer_customer_id_seq OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: employee; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.employee (
eid character varying(100),
name character varying(100),
job_title character varying(100),
department character varying(100),
business_unit character varying(100),
gender character varying(10),
ethnicity character varying(100),
age integer,
annual_salary numeric(15,2),
bonus_percentage numeric(15,2),
country character varying(100),
city character varying(100),
id integer NOT NULL,
department_id integer,
departmnt character varying(100)
);
ALTER TABLE public.employee OWNER TO postgres;
--
-- Name: employee_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.employee_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.employee_id_seq OWNER TO postgres;
--
-- Name: employee_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.employee_id_seq OWNED BY public.employee.id;
--
-- Name: film_film_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.film_film_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.film_film_id_seq OWNER TO postgres;
--
-- Name: inventory_inventory_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.inventory_inventory_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.inventory_inventory_id_seq OWNER TO postgres;
--
-- Name: language_language_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.language_language_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.language_language_id_seq OWNER TO postgres;
--
-- Name: payment_payment_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.payment_payment_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.payment_payment_id_seq OWNER TO postgres;
--
-- Name: rental_rental_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.rental_rental_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.rental_rental_id_seq OWNER TO postgres;
--
-- Name: staff_staff_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.staff_staff_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.staff_staff_id_seq OWNER TO postgres;
--
-- Name: store_store_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.store_store_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.store_store_id_seq OWNER TO postgres;
--
-- Name: employee id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.employee ALTER COLUMN id SET DEFAULT nextval('public.employee_id_seq'::regclass);
--
-- Name: employee employee_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.employee
ADD CONSTRAINT employee_pkey PRIMARY KEY (id);
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: pg_database_owner
--
REVOKE USAGE ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,259 @@
-- Downloaded from: https://github.com/amittannagit/World-Cup-database-project-files/blob/cb5dec9fd4d74e0d28e2fc60ffd1e726e9eb1a08/worldcup.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.17 (Ubuntu 12.17-1.pgdg22.04+1)
-- Dumped by pg_dump version 12.17 (Ubuntu 12.17-1.pgdg22.04+1)
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;
DROP DATABASE worldcup;
--
-- Name: worldcup; Type: DATABASE; Schema: -; Owner: freecodecamp
--
CREATE DATABASE worldcup WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'C.UTF-8';
ALTER DATABASE worldcup OWNER TO freecodecamp;
\connect worldcup
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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: games; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.games (
game_id integer NOT NULL,
year integer NOT NULL,
round character varying(50) NOT NULL,
winner_id integer NOT NULL,
opponent_id integer NOT NULL,
winner_goals integer NOT NULL,
opponent_goals integer NOT NULL
);
ALTER TABLE public.games OWNER TO freecodecamp;
--
-- Name: games_game_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.games_game_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.games_game_id_seq OWNER TO freecodecamp;
--
-- Name: games_game_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.games_game_id_seq OWNED BY public.games.game_id;
--
-- Name: teams; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.teams (
team_id integer NOT NULL,
name character varying(50) NOT NULL
);
ALTER TABLE public.teams OWNER TO freecodecamp;
--
-- Name: teams_team_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.teams_team_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.teams_team_id_seq OWNER TO freecodecamp;
--
-- Name: teams_team_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.teams_team_id_seq OWNED BY public.teams.team_id;
--
-- Name: games game_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.games ALTER COLUMN game_id SET DEFAULT nextval('public.games_game_id_seq'::regclass);
--
-- Name: teams team_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.teams ALTER COLUMN team_id SET DEFAULT nextval('public.teams_team_id_seq'::regclass);
--
-- Data for Name: games; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
INSERT INTO public.games VALUES (1, 2018, 'Final', 1, 2, 4, 2);
INSERT INTO public.games VALUES (2, 2018, 'Third Place', 3, 4, 2, 0);
INSERT INTO public.games VALUES (3, 2018, 'Semi-Final', 2, 4, 2, 1);
INSERT INTO public.games VALUES (4, 2018, 'Semi-Final', 1, 3, 1, 0);
INSERT INTO public.games VALUES (5, 2018, 'Quarter-Final', 2, 10, 3, 2);
INSERT INTO public.games VALUES (6, 2018, 'Quarter-Final', 4, 12, 2, 0);
INSERT INTO public.games VALUES (7, 2018, 'Quarter-Final', 3, 14, 2, 1);
INSERT INTO public.games VALUES (8, 2018, 'Quarter-Final', 1, 16, 2, 0);
INSERT INTO public.games VALUES (9, 2018, 'Eighth-Final', 4, 18, 2, 1);
INSERT INTO public.games VALUES (10, 2018, 'Eighth-Final', 12, 20, 1, 0);
INSERT INTO public.games VALUES (11, 2018, 'Eighth-Final', 3, 22, 3, 2);
INSERT INTO public.games VALUES (12, 2018, 'Eighth-Final', 14, 24, 2, 0);
INSERT INTO public.games VALUES (13, 2018, 'Eighth-Final', 2, 26, 2, 1);
INSERT INTO public.games VALUES (14, 2018, 'Eighth-Final', 10, 28, 2, 1);
INSERT INTO public.games VALUES (15, 2018, 'Eighth-Final', 16, 30, 2, 1);
INSERT INTO public.games VALUES (16, 2018, 'Eighth-Final', 1, 32, 4, 3);
INSERT INTO public.games VALUES (17, 2014, 'Final', 33, 32, 1, 0);
INSERT INTO public.games VALUES (18, 2014, 'Third Place', 35, 14, 3, 0);
INSERT INTO public.games VALUES (19, 2014, 'Semi-Final', 32, 35, 1, 0);
INSERT INTO public.games VALUES (20, 2014, 'Semi-Final', 33, 14, 7, 1);
INSERT INTO public.games VALUES (21, 2014, 'Quarter-Final', 35, 42, 1, 0);
INSERT INTO public.games VALUES (22, 2014, 'Quarter-Final', 32, 3, 1, 0);
INSERT INTO public.games VALUES (23, 2014, 'Quarter-Final', 14, 18, 2, 1);
INSERT INTO public.games VALUES (24, 2014, 'Quarter-Final', 33, 1, 1, 0);
INSERT INTO public.games VALUES (25, 2014, 'Eighth-Final', 14, 50, 2, 1);
INSERT INTO public.games VALUES (26, 2014, 'Eighth-Final', 18, 16, 2, 0);
INSERT INTO public.games VALUES (27, 2014, 'Eighth-Final', 1, 54, 2, 0);
INSERT INTO public.games VALUES (28, 2014, 'Eighth-Final', 33, 56, 2, 1);
INSERT INTO public.games VALUES (29, 2014, 'Eighth-Final', 35, 24, 2, 1);
INSERT INTO public.games VALUES (30, 2014, 'Eighth-Final', 42, 60, 2, 1);
INSERT INTO public.games VALUES (31, 2014, 'Eighth-Final', 32, 20, 1, 0);
INSERT INTO public.games VALUES (32, 2014, 'Eighth-Final', 3, 64, 2, 1);
--
-- Data for Name: teams; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
INSERT INTO public.teams VALUES (1, 'France');
INSERT INTO public.teams VALUES (2, 'Croatia');
INSERT INTO public.teams VALUES (3, 'Belgium');
INSERT INTO public.teams VALUES (4, 'England');
INSERT INTO public.teams VALUES (10, 'Russia');
INSERT INTO public.teams VALUES (12, 'Sweden');
INSERT INTO public.teams VALUES (14, 'Brazil');
INSERT INTO public.teams VALUES (16, 'Uruguay');
INSERT INTO public.teams VALUES (18, 'Colombia');
INSERT INTO public.teams VALUES (20, 'Switzerland');
INSERT INTO public.teams VALUES (22, 'Japan');
INSERT INTO public.teams VALUES (24, 'Mexico');
INSERT INTO public.teams VALUES (26, 'Denmark');
INSERT INTO public.teams VALUES (28, 'Spain');
INSERT INTO public.teams VALUES (30, 'Portugal');
INSERT INTO public.teams VALUES (32, 'Argentina');
INSERT INTO public.teams VALUES (33, 'Germany');
INSERT INTO public.teams VALUES (35, 'Netherlands');
INSERT INTO public.teams VALUES (42, 'Costa Rica');
INSERT INTO public.teams VALUES (50, 'Chile');
INSERT INTO public.teams VALUES (54, 'Nigeria');
INSERT INTO public.teams VALUES (56, 'Algeria');
INSERT INTO public.teams VALUES (60, 'Greece');
INSERT INTO public.teams VALUES (64, 'United States');
--
-- Name: games_game_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.games_game_id_seq', 32, true);
--
-- Name: teams_team_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.teams_team_id_seq', 64, true);
--
-- Name: games games_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.games
ADD CONSTRAINT games_pkey PRIMARY KEY (game_id);
--
-- Name: teams teams_name_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.teams
ADD CONSTRAINT teams_name_key UNIQUE (name);
--
-- Name: teams teams_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.teams
ADD CONSTRAINT teams_pkey PRIMARY KEY (team_id);
--
-- Name: games games_opponent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.games
ADD CONSTRAINT games_opponent_id_fkey FOREIGN KEY (opponent_id) REFERENCES public.teams(team_id);
--
-- Name: games games_winner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.games
ADD CONSTRAINT games_winner_id_fkey FOREIGN KEY (winner_id) REFERENCES public.teams(team_id);
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
+243
View File
@@ -0,0 +1,243 @@
-- Downloaded from: https://github.com/bartr/agency/blob/9e8f7185023b3616a144f56b0bbbc0f7cb89b37d/sql/cnp.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 13.4 (Debian 13.4-4.pgdg110+1)
-- Dumped by pg_dump version 13.4 (Debian 13.4-4.pgdg110+1)
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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: update_modified(); Type: FUNCTION; Schema: public; Owner: root
--
CREATE FUNCTION public.update_modified() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.modified_ = now();
RETURN NEW;
END;
$$;
ALTER FUNCTION public.update_modified() OWNER TO root;
--
-- Name: children; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.children (
parentid integer NOT NULL,
childid integer NOT NULL,
sortorder integer DEFAULT 100
);
ALTER TABLE public.children OWNER TO root;
--
-- Name: links; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.links (
id integer NOT NULL,
path character varying(400) NOT NULL,
type integer NOT NULL,
description character varying(64000) NOT NULL,
owner character varying(100) NOT NULL,
target character varying(400) DEFAULT ''::character varying NOT NULL,
content character varying(64000) DEFAULT ''::character varying NOT NULL,
isprivate boolean DEFAULT false NOT NULL,
created_ timestamp(0) with time zone DEFAULT now() NOT NULL,
modified_ timestamp(0) with time zone DEFAULT now() NOT NULL,
title character varying(400) DEFAULT ''::character varying NOT NULL,
tags json DEFAULT '[]'::json NOT NULL,
template character varying(16000) DEFAULT ''::character varying NOT NULL,
html character varying(64000) DEFAULT ''::character varying NOT NULL,
orderby character varying(8000) DEFAULT ''::character varying NOT NULL,
tenant character varying(100) DEFAULT '*'::character varying NOT NULL,
sortorder integer DEFAULT 100 NOT NULL,
theme character varying(400) DEFAULT 'blue'::character varying NOT NULL,
title2 character varying(400) DEFAULT ''::character varying NOT NULL,
thumbnail character varying(400) DEFAULT ''::character varying,
background character varying(400) DEFAULT ''::character varying,
facebook character varying(200) DEFAULT ''::character varying,
github character varying(200) DEFAULT ''::character varying,
instagram character varying(200) DEFAULT ''::character varying,
linkedin character varying(200) DEFAULT ''::character varying,
twitter character varying(200) DEFAULT ''::character varying,
youtube character varying(200) DEFAULT ''::character varying,
web character varying(200) DEFAULT ''::character varying
);
ALTER TABLE public.links OWNER TO root;
--
-- Name: links_id_seq; Type: SEQUENCE; Schema: public; Owner: root
--
ALTER TABLE public.links ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.links_id_seq
START WITH 101
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: logs; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.logs (
id integer NOT NULL,
date timestamp(3) with time zone NOT NULL,
statuscode integer NOT NULL,
path character varying(400) NOT NULL,
duration integer NOT NULL,
contentlength integer NOT NULL,
method character varying(10) NOT NULL,
host character varying(100) DEFAULT ''::character varying NOT NULL,
ipaddress character varying(20) DEFAULT ''::character varying NOT NULL,
querystring character varying(400) DEFAULT ''::character varying NOT NULL,
referrer character varying(400) DEFAULT ''::character varying NOT NULL,
useragent character varying(400) DEFAULT ''::character varying NOT NULL,
ismobile boolean DEFAULT false NOT NULL,
userid character varying(100) DEFAULT ''::character varying NOT NULL,
category character varying(100) DEFAULT ''::character varying NOT NULL,
tag character varying(100) DEFAULT ''::character varying NOT NULL
);
ALTER TABLE public.logs OWNER TO root;
--
-- Name: logs_id_seq; Type: SEQUENCE; Schema: public; Owner: root
--
ALTER TABLE public.logs ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.logs_id_seq
START WITH 101
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: users; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.users (
id character varying(50) NOT NULL,
isadmin boolean DEFAULT false NOT NULL,
token character varying(200) DEFAULT ''::character varying NOT NULL,
cookie character varying(200) DEFAULT ''::character varying NOT NULL,
github character varying(200) DEFAULT ''::character varying NOT NULL,
linkedin character varying(200) DEFAULT ''::character varying NOT NULL,
twitter character varying(200) DEFAULT ''::character varying NOT NULL,
facebook character varying(200) DEFAULT ''::character varying,
instagram character varying(200) DEFAULT ''::character varying,
youtube character varying(200) DEFAULT ''::character varying
);
ALTER TABLE public.users OWNER TO root;
--
-- Data for Name: children; Type: TABLE DATA; Schema: public; Owner: root
--
COPY public.children (parentid, childid, sortorder) FROM stdin;
0 101 1
0 103 100
0 104 100
101 102 100
\.
--
-- Data for Name: links; Type: TABLE DATA; Schema: public; Owner: root
--
COPY public.links (id, path, type, description, owner, target, content, isprivate, created_, modified_, title, tags, template, html, orderby, tenant, sortorder, theme, title2, thumbnail, background, facebook, github, instagram, linkedin, twitter, youtube, web) FROM stdin;
0 / 0 <h1>Welcome to CNP Labs</h1>Under construction ... cnp Welcome to CNP Labs Under construction f 2021-11-09 21:02:18+00 2021-11-09 21:28:38+00 CNP Labs [] cnp-tree cnp.dev 100 orange https://cnp.dev/github
1 /github 1 CNP Labs GitHub cnp https://github.com/cnp-labs /github\nCNP Labs GitHub\nhttps://github.com/cnp-labs\nCNP Labs GitHub f 2021-11-09 21:15:16+00 2021-11-09 21:28:38+00 CNP Labs GitHub [] cnp.dev 100 orange
2 /gh 1 CNP Labs GitHub cnp https://github.com/cnp-labs /gh\nCNP Labs GitHub\nhttps://github.com/cnp-labs\nCNP Labs GitHub f 2021-11-09 21:15:31+00 2021-11-09 21:28:38+00 CNP Labs GitHub [] cnp.dev 100 orange
101 /demos 0 Demo videos cnp /demos\nDemo Videos\nDemo videos f 2021-11-09 21:10:32+00 2021-11-09 21:30:16+00 Demo Videos [] cnp-tree cnp.dev 1 orange CNP Labs
102 /demos/devx 1 CNP Labs Developer Experience Demo Video cnp https://cnp.dev/cnp/content/CNP-Labs-DevX.mp4 DevX Demo CNP Labs Developer Experience Demo Video f 2021-11-09 21:11:25+00 2021-11-09 21:28:38+00 DevX Demo [] cnp.dev 100 orange
103 /blog 0 CNP Labs Blog cnp /blog\nOur Blog\nCNP Labs Blog f 2021-11-09 21:24:12+00 2021-11-09 21:28:57+00 Our Blog [] cnp-tree Under Construction cnp.dev 100 orange CNP Labs
104 /about 0 About CNP Labs cnp /about\nAbout Us\nAbout CNP Labs f 2021-11-09 21:24:33+00 2021-11-09 21:28:57+00 About Us [] cnp-tree About CNP Labs cnp.dev 100 orange CNP Labs
\.
--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: root
--
COPY public.users (id, isadmin, token, github) FROM stdin;
bartr t Table512
matt t Agency512
cnp t 512Table https://github.com/cnp-labs
\.
--
-- Name: links_id_seq; Type: SEQUENCE SET; Schema: public; Owner: root
--
SELECT pg_catalog.setval('public.links_id_seq', 105, true);
--
-- Name: children children_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.children
ADD CONSTRAINT children_pkey PRIMARY KEY (parentid, childid);
--
-- Name: links links_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.links
ADD CONSTRAINT links_pkey PRIMARY KEY (id);
--
-- Name: logs logs_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.logs
ADD CONSTRAINT logs_pkey PRIMARY KEY (id);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: links modified_trigger; Type: TRIGGER; Schema: public; Owner: root
--
CREATE TRIGGER modified_trigger BEFORE UPDATE ON public.links FOR EACH ROW EXECUTE FUNCTION public.update_modified();
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,287 @@
-- Downloaded from: https://github.com/by-zah/universityScheduleBot/blob/c8e0034ca23d8f0cac3c0ae6d5f4968ebb4be207/emptyDump.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.3 (Ubuntu 12.3-1.pgdg16.04+1)
-- Dumped by pg_dump version 12.4
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;
DROP DATABASE IF EXISTS d7tmbubts2qa9a;
--
-- Name: d7tmbubts2qa9a; Type: DATABASE; Schema: -; Owner: hayrdyszkbigyi
--
CREATE DATABASE d7tmbubts2qa9a WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
ALTER DATABASE d7tmbubts2qa9a OWNER TO hayrdyszkbigyi;
\connect d7tmbubts2qa9a
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;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: hayrdyszkbigyi
--
CREATE SCHEMA public;
ALTER SCHEMA public OWNER TO hayrdyszkbigyi;
--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: hayrdyszkbigyi
--
COMMENT ON SCHEMA public IS 'standard public schema';
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: classes; Type: TABLE; Schema: public; Owner: hayrdyszkbigyi
--
CREATE TABLE public.classes (
index integer NOT NULL,
group_name character varying(255) NOT NULL,
day integer NOT NULL,
building character varying(255),
name character varying(255),
room_number character varying(255)
);
ALTER TABLE public.classes OWNER TO hayrdyszkbigyi;
--
-- Name: groups; Type: TABLE; Schema: public; Owner: hayrdyszkbigyi
--
CREATE TABLE public.groups (
name character varying(255) NOT NULL,
owner_id integer
);
ALTER TABLE public.groups OWNER TO hayrdyszkbigyi;
--
-- Name: schedule; Type: TABLE; Schema: public; Owner: hayrdyszkbigyi
--
CREATE TABLE public.schedule (
index integer NOT NULL,
end_hour integer,
end_min integer,
start_hour integer,
start_min integer
);
ALTER TABLE public.schedule OWNER TO hayrdyszkbigyi;
--
-- Name: subscriptions; Type: TABLE; Schema: public; Owner: hayrdyszkbigyi
--
CREATE TABLE public.subscriptions (
user_chat_id bigint NOT NULL,
"group" character varying(255) NOT NULL
);
ALTER TABLE public.subscriptions OWNER TO hayrdyszkbigyi;
--
-- Name: users; Type: TABLE; Schema: public; Owner: hayrdyszkbigyi
--
CREATE TABLE public.users (
id integer NOT NULL,
chat_id bigint NOT NULL,
interfaculty_discipline character varying(255),
local character varying(255),
is_supper boolean DEFAULT false
);
ALTER TABLE public.users OWNER TO hayrdyszkbigyi;
--
-- Data for Name: classes; Type: TABLE DATA; Schema: public; Owner: hayrdyszkbigyi
--
COPY public.classes (index, group_name, day, building, name, room_number) FROM stdin;
\.
--
-- Data for Name: groups; Type: TABLE DATA; Schema: public; Owner: hayrdyszkbigyi
--
COPY public.groups (name, owner_id) FROM stdin;
\.
--
-- Data for Name: schedule; Type: TABLE DATA; Schema: public; Owner: hayrdyszkbigyi
--
COPY public.schedule (index, end_hour, end_min, start_hour, start_min) FROM stdin;
\.
--
-- Data for Name: subscriptions; Type: TABLE DATA; Schema: public; Owner: hayrdyszkbigyi
--
COPY public.subscriptions (user_chat_id, "group") FROM stdin;
\.
--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: hayrdyszkbigyi
--
COPY public.users (id, chat_id, interfaculty_discipline, local, is_supper) FROM stdin;
\.
--
-- Name: classes classes_pkey; Type: CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.classes
ADD CONSTRAINT classes_pkey PRIMARY KEY (index, group_name, day);
--
-- Name: groups groups_pkey; Type: CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.groups
ADD CONSTRAINT groups_pkey PRIMARY KEY (name);
--
-- Name: schedule schedule_pkey; Type: CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.schedule
ADD CONSTRAINT schedule_pkey PRIMARY KEY (index);
--
-- Name: subscriptions subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.subscriptions
ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (user_chat_id, "group");
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: users_chat_id_uindex; Type: INDEX; Schema: public; Owner: hayrdyszkbigyi
--
CREATE UNIQUE INDEX users_chat_id_uindex ON public.users USING btree (chat_id);
--
-- Name: classes classes_groups_name_fk; Type: FK CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.classes
ADD CONSTRAINT classes_groups_name_fk FOREIGN KEY (group_name) REFERENCES public.groups(name) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- Name: classes classes_schedule_index_fk; Type: FK CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.classes
ADD CONSTRAINT classes_schedule_index_fk FOREIGN KEY (index) REFERENCES public.schedule(index);
--
-- Name: groups groups_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.groups
ADD CONSTRAINT groups_users_id_fk FOREIGN KEY (owner_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- Name: subscriptions subscriptions_groups_name_fk; Type: FK CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.subscriptions
ADD CONSTRAINT subscriptions_groups_name_fk FOREIGN KEY ("group") REFERENCES public.groups(name) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- Name: subscriptions subscriptions_users_chat_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: hayrdyszkbigyi
--
ALTER TABLE ONLY public.subscriptions
ADD CONSTRAINT subscriptions_users_chat_id_fk FOREIGN KEY (user_chat_id) REFERENCES public.users(chat_id) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- Name: DATABASE d7tmbubts2qa9a; Type: ACL; Schema: -; Owner: hayrdyszkbigyi
--
REVOKE CONNECT,TEMPORARY ON DATABASE d7tmbubts2qa9a FROM PUBLIC;
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: hayrdyszkbigyi
--
REVOKE ALL ON SCHEMA public FROM postgres;
REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO hayrdyszkbigyi;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- Name: LANGUAGE plpgsql; Type: ACL; Schema: -; Owner: postgres
--
GRANT ALL ON LANGUAGE plpgsql TO hayrdyszkbigyi;
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,363 @@
-- Downloaded from: https://github.com/dbarrera98/proyecto-informa/blob/f6d6e700a5f20ffa272f728a83af6eb3683c3b83/initdb/init.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.1
-- Dumped by pg_dump version 16.1
-- Started on 2025-05-31 16:18:14
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;
--
-- TOC entry 224 (class 1255 OID 24614)
-- Name: actualizar_autor(integer, character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.actualizar_autor(p_id integer, p_nombre character varying) RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
v_count INTEGER;
BEGIN
SELECT COUNT(*) INTO v_count FROM autores a WHERE a.id = p_id;
IF v_count = 0 THEN
RAISE EXCEPTION 'Autor no existe';
END IF;
UPDATE autores a SET nombre = p_nombre WHERE a.id = p_id;
END;
$$;
ALTER FUNCTION public.actualizar_autor(p_id integer, p_nombre character varying) OWNER TO postgres;
--
-- TOC entry 225 (class 1255 OID 24610)
-- Name: actualizar_libro(integer, character varying, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.actualizar_libro(p_id integer, p_titulo character varying, p_autor_id integer) RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
v_count INTEGER;
BEGIN
SELECT COUNT(*) INTO v_count FROM autores a WHERE a.id = p_autor_id;
IF v_count = 0 THEN
RAISE EXCEPTION 'Autor no existe';
END IF;
SELECT COUNT(*) INTO v_count FROM libros l WHERE l.id = p_id;
IF v_count = 0 THEN
RAISE EXCEPTION 'Libro no existe';
END IF;
UPDATE libros l SET titulo = p_titulo, autor_id = p_autor_id WHERE l.id = p_id;
END;
$$;
ALTER FUNCTION public.actualizar_libro(p_id integer, p_titulo character varying, p_autor_id integer) OWNER TO postgres;
--
-- TOC entry 223 (class 1255 OID 24616)
-- Name: consultar_autor(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.consultar_autor(p_id integer) RETURNS TABLE(id integer, nombre character varying)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY SELECT a.id, a.nombre FROM autores a WHERE a.id = p_id;
END;
$$;
ALTER FUNCTION public.consultar_autor(p_id integer) OWNER TO postgres;
--
-- TOC entry 222 (class 1255 OID 24617)
-- Name: consultar_autores(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.consultar_autores() RETURNS TABLE(id integer, nombre character varying)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT a.id, a.nombre FROM autores a;
END;
$$;
ALTER FUNCTION public.consultar_autores() OWNER TO postgres;
--
-- TOC entry 220 (class 1255 OID 24612)
-- Name: consultar_libro(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.consultar_libro(p_id integer) RETURNS TABLE(id integer, titulo character varying, autor_id integer)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY SELECT l.id, l.titulo, l.autor_id FROM libros l WHERE l.id = p_id;
END;
$$;
ALTER FUNCTION public.consultar_libro(p_id integer) OWNER TO postgres;
--
-- TOC entry 226 (class 1255 OID 24613)
-- Name: consultar_libros(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.consultar_libros() RETURNS TABLE(id integer, titulo character varying, autor_id integer)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY SELECT l.id, l.titulo, l.autor_id FROM libros l;
END;
$$;
ALTER FUNCTION public.consultar_libros() OWNER TO postgres;
--
-- TOC entry 232 (class 1255 OID 24615)
-- Name: eliminar_autor(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.eliminar_autor(p_id integer) RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
v_count INTEGER;
BEGIN
SELECT COUNT(*) INTO v_count FROM autores a WHERE a.id = p_id;
IF v_count = 0 THEN
RAISE EXCEPTION 'Autor no existe';
END IF;
SELECT COUNT(*) INTO v_count FROM libros l WHERE l.autor_id = p_id;
IF v_count > 0 THEN
RAISE EXCEPTION 'No se puede eliminar el autor porque tiene libros asociados';
END IF;
DELETE FROM autores a WHERE a.id = p_id;
RAISE NOTICE 'Autor eliminado exitosamente (id = %)', p_id;
END;
$$;
ALTER FUNCTION public.eliminar_autor(p_id integer) OWNER TO postgres;
--
-- TOC entry 221 (class 1255 OID 24611)
-- Name: eliminar_libro(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.eliminar_libro(p_id integer) RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
v_count INTEGER;
BEGIN
SELECT COUNT(*) INTO v_count FROM libros l WHERE l.id = p_id;
IF v_count = 0 THEN
RAISE EXCEPTION 'Libro no existe';
END IF;
DELETE FROM libros l WHERE l.id = p_id;
END;
$$;
ALTER FUNCTION public.eliminar_libro(p_id integer) OWNER TO postgres;
--
-- TOC entry 219 (class 1255 OID 24608)
-- Name: insertar_autor(character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.insertar_autor(p_nombre character varying) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
INSERT INTO autores (nombre) VALUES (p_nombre);
END;
$$;
ALTER FUNCTION public.insertar_autor(p_nombre character varying) OWNER TO postgres;
--
-- TOC entry 227 (class 1255 OID 24609)
-- Name: insertar_libro(character varying, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.insertar_libro(p_titulo character varying, p_autor_id integer) RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
v_count INTEGER;
BEGIN
SELECT COUNT(*) INTO v_count FROM autores a WHERE a.id = p_autor_id;
IF v_count = 0 THEN
RAISE EXCEPTION 'Autor no existe';
END IF;
INSERT INTO libros (titulo, autor_id) VALUES (p_titulo, p_autor_id);
END;
$$;
ALTER FUNCTION public.insertar_libro(p_titulo character varying, p_autor_id integer) OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 216 (class 1259 OID 24592)
-- Name: autores; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.autores (
id integer NOT NULL,
nombre character varying(100) NOT NULL
);
ALTER TABLE public.autores OWNER TO postgres;
--
-- TOC entry 215 (class 1259 OID 24591)
-- Name: autores_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.autores ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.autores_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 218 (class 1259 OID 24598)
-- Name: libros; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.libros (
id integer NOT NULL,
titulo character varying(200) NOT NULL,
autor_id integer NOT NULL
);
ALTER TABLE public.libros OWNER TO postgres;
--
-- TOC entry 217 (class 1259 OID 24597)
-- Name: libros_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.libros ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.libros_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- TOC entry 4798 (class 0 OID 24592)
-- Dependencies: 216
-- Data for Name: autores; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.autores (id, nombre) FROM stdin;
8 Camilo
5 Andres
12 William
13 Jane
11 Cervantes
14 Mary
15 Laura
\.
--
-- TOC entry 4800 (class 0 OID 24598)
-- Dependencies: 218
-- Data for Name: libros; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.libros (id, titulo, autor_id) FROM stdin;
4 Don Quijote de la Mancha 11
6 Frankenstein 14
8 Los caracoles 15
\.
--
-- TOC entry 4806 (class 0 OID 0)
-- Dependencies: 215
-- Name: autores_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.autores_id_seq', 15, true);
--
-- TOC entry 4807 (class 0 OID 0)
-- Dependencies: 217
-- Name: libros_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.libros_id_seq', 8, true);
--
-- TOC entry 4650 (class 2606 OID 24596)
-- Name: autores autores_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.autores
ADD CONSTRAINT autores_pkey PRIMARY KEY (id);
--
-- TOC entry 4652 (class 2606 OID 24602)
-- Name: libros libros_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.libros
ADD CONSTRAINT libros_pkey PRIMARY KEY (id);
--
-- TOC entry 4653 (class 2606 OID 24603)
-- Name: libros libros_autor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.libros
ADD CONSTRAINT libros_autor_id_fkey FOREIGN KEY (autor_id) REFERENCES public.autores(id);
-- Completed on 2025-05-31 16:18:17
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,826 @@
-- Downloaded from: https://github.com/gabrundo/Progetto-Basi-Dati/blob/f8270e116533e237f55d1ef56bcd7a0a0f94f17b/dump_uni.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.19
-- Dumped by pg_dump version 11.19
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;
--
-- Name: uni; Type: SCHEMA; Schema: -; Owner: bitnami
--
CREATE SCHEMA uni;
ALTER SCHEMA uni OWNER TO bitnami;
--
-- Name: anno_insegnamento(); Type: FUNCTION; Schema: uni; Owner: bitnami
--
CREATE FUNCTION uni.anno_insegnamento() RETURNS trigger
LANGUAGE plpgsql
AS $$
declare
tipo corso_laurea.tipologia%type;
begin
select tipologia into tipo
from corso_laurea
where nome = new.corso_laurea;
if tipo = 'Triennale' then
if not (new.anno = '1' or new.anno = '2' or new.anno = '3') then
raise exception 'Inserimento del insegnamento % non valido!', new.nome;
return null;
end if;
elsif tipo = 'Magistrale' then
if not (new.anno = '1' or new.anno = '2') then
raise exception 'Inserimento del insegnamento % non valido!', new.nome;
return null;
end if;
end if;
return new;
end;
$$;
ALTER FUNCTION uni.anno_insegnamento() OWNER TO bitnami;
--
-- Name: appelli_esami(); Type: FUNCTION; Schema: uni; Owner: bitnami
--
CREATE FUNCTION uni.appelli_esami() RETURNS trigger
LANGUAGE plpgsql
AS $$
declare
anno_esame insegnamento.anno%type;
begin
select anno into anno_esame
from insegnamento
where corso_laurea = new.corso_laurea and codice = new.codice;
perform *
from insegnamento i inner join appello a on a.corso_laurea = i.corso_laurea and a.codice = i.codice
where i.corso_laurea = new.corso_laurea and i.anno = anno_esame and data = new.data;
if found then
raise exception 'Impossibile inserire appello per una sovrapposizione';
return null;
else
return new;
end if;
end;
$$;
ALTER FUNCTION uni.appelli_esami() OWNER TO bitnami;
--
-- Name: descrizione_corso_laurea(character varying); Type: FUNCTION; Schema: uni; Owner: bitnami
--
CREATE FUNCTION uni.descrizione_corso_laurea(character varying) RETURNS text
LANGUAGE plpgsql
AS $_$
declare
descrizione text = '';
corso corso_laurea%rowtype;
ins insegnamento%rowtype;
begin
select * into corso
from corso_laurea
where trim(lower(nome)) = trim(lower($1));
if not found then
raise exception 'Nome del corso non trovato';
else
descrizione = descrizione || 'Nome corso di laurea: ' || corso.nome
|| ', tipologia: ' || corso.tipologia || ', facoltà: ' || corso.segreteria || E'\n';
for ins in
select *
from insegnamento
where trim(lower(nome)) = trim(lower($1))
order by anno asc
loop
descrizione = descrizione || 'nome esame: ' || ins.nome
|| ', anno di erogazione : ' || ins.anno || ', descrizione: ' || ins.descrizione
|| ', responsabile: ' || ins.responsabile || E'\n';
end loop;
end if;
return descrizione;
end;
$_$;
ALTER FUNCTION uni.descrizione_corso_laurea(character varying) OWNER TO bitnami;
--
-- Name: iscrizione_esami(); Type: FUNCTION; Schema: uni; Owner: bitnami
--
CREATE FUNCTION uni.iscrizione_esami() RETURNS trigger
LANGUAGE plpgsql
AS $$
declare
cois propedeuticita.corso_is%type;
cdis propedeuticita.codice_is%type;
begin
perform *
from insegnamento
where corso_laurea = new.corso_laurea and codice = new.codice;
if found then
for cois, cdis in
select corso_is, codice_is
from propedeuticita
where corso_has = new.corso_laurea and codice_has = new.codice
loop
if found then
perform *
from sostiene
where corso_laurea = cois and codice = cdis
and studente = new.studente and voto > 17 and data < new.data;
if not found then
raise exception 'Propedeuticità non rispettate per il corso %', cois;
return null;
end if;
end if;
end loop;
else
raise info 'Insegnamento % non registrato', cois;
return null;
end if;
return new;
end;
$$;
ALTER FUNCTION uni.iscrizione_esami() OWNER TO bitnami;
--
-- Name: numero_insegnamenti_docente(); Type: FUNCTION; Schema: uni; Owner: bitnami
--
CREATE FUNCTION uni.numero_insegnamenti_docente() RETURNS trigger
LANGUAGE plpgsql
AS $$
declare
resp insegnamento.responsabile%type;
numero numeric;
begin
select responsabile, count(*) into resp, numero
from insegnamento
group by responsabile
having count(*) > 3;
if found then
raise exception 'Il docente, con identificativo %, non può gestire altri corsi!', resp;
delete from insegnamento where corso_laurea = new.corso_laurea and codice = new.codice;
end if;
return null;
end;
$$;
ALTER FUNCTION uni.numero_insegnamenti_docente() OWNER TO bitnami;
--
-- Name: str_studente_carriera(); Type: FUNCTION; Schema: uni; Owner: bitnami
--
CREATE FUNCTION uni.str_studente_carriera() RETURNS trigger
LANGUAGE plpgsql
AS $$
begin
insert into str_studente (matricola, email, nome, cognome, corso_laurea)
values (old.matricola, old.email, old.nome, old.cognome, old.corso_laurea);
insert into str_sostiene
select *
from sostiene
where studente = old.matricola;
delete
from sostiene
where studente=old.matricola;
return old;
end;
$$;
ALTER FUNCTION uni.str_studente_carriera() OWNER TO bitnami;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: appello; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.appello (
corso_laurea character varying NOT NULL,
codice character(3) NOT NULL,
data date NOT NULL
);
ALTER TABLE uni.appello OWNER TO bitnami;
--
-- Name: insegnamento; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.insegnamento (
corso_laurea character varying NOT NULL,
codice character(3) NOT NULL,
nome character varying NOT NULL,
anno character(1) NOT NULL,
descrizione text NOT NULL,
responsabile character varying
);
ALTER TABLE uni.insegnamento OWNER TO bitnami;
--
-- Name: sostiene; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.sostiene (
studente character(6) NOT NULL,
corso_laurea character varying NOT NULL,
codice character(3) NOT NULL,
data date NOT NULL,
voto smallint,
CONSTRAINT voto_valido CHECK (((0 <= voto) AND (voto <= 30)))
);
ALTER TABLE uni.sostiene OWNER TO bitnami;
--
-- Name: carriera_completa; Type: VIEW; Schema: uni; Owner: bitnami
--
CREATE VIEW uni.carriera_completa AS
SELECT s.studente,
i.nome,
a.corso_laurea,
i.anno,
a.data,
s.voto
FROM ((uni.appello a
JOIN uni.sostiene s ON ((((a.corso_laurea)::text = (s.corso_laurea)::text) AND (a.codice = s.codice) AND (a.data = s.data))))
JOIN uni.insegnamento i ON ((((a.corso_laurea)::text = (i.corso_laurea)::text) AND (a.codice = i.codice))));
ALTER TABLE uni.carriera_completa OWNER TO bitnami;
--
-- Name: str_sostiene; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.str_sostiene (
studente character(6) NOT NULL,
corso_laurea character varying NOT NULL,
codice character(3) NOT NULL,
data date NOT NULL,
voto smallint
);
ALTER TABLE uni.str_sostiene OWNER TO bitnami;
--
-- Name: carriera_completa_globale; Type: VIEW; Schema: uni; Owner: bitnami
--
CREATE VIEW uni.carriera_completa_globale AS
WITH sostiene_globale AS (
SELECT sostiene.studente,
sostiene.corso_laurea,
sostiene.codice,
sostiene.data,
sostiene.voto
FROM uni.sostiene
UNION
SELECT str_sostiene.studente,
str_sostiene.corso_laurea,
str_sostiene.codice,
str_sostiene.data,
str_sostiene.voto
FROM uni.str_sostiene
)
SELECT s.studente,
i.nome,
a.corso_laurea,
i.anno,
a.data,
s.voto
FROM ((uni.appello a
JOIN sostiene_globale s ON ((((a.corso_laurea)::text = (s.corso_laurea)::text) AND (a.codice = s.codice) AND (a.data = s.data))))
JOIN uni.insegnamento i ON ((((a.corso_laurea)::text = (i.corso_laurea)::text) AND (a.codice = i.codice))));
ALTER TABLE uni.carriera_completa_globale OWNER TO bitnami;
--
-- Name: carriera_valida; Type: VIEW; Schema: uni; Owner: bitnami
--
CREATE VIEW uni.carriera_valida AS
WITH esami_recenti AS (
SELECT carriera_completa.studente,
carriera_completa.nome,
carriera_completa.corso_laurea,
carriera_completa.anno,
max(carriera_completa.data) AS data_recente
FROM uni.carriera_completa
WHERE (carriera_completa.voto > 17)
GROUP BY carriera_completa.studente, carriera_completa.nome, carriera_completa.corso_laurea, carriera_completa.anno
)
SELECT e.studente,
e.nome,
e.corso_laurea,
e.anno,
e.data_recente,
c.voto
FROM (esami_recenti e
JOIN uni.carriera_completa c ON (((e.studente = c.studente) AND ((e.nome)::text = (c.nome)::text) AND ((e.corso_laurea)::text = (c.corso_laurea)::text) AND (e.data_recente = c.data))));
ALTER TABLE uni.carriera_valida OWNER TO bitnami;
--
-- Name: carriera_valida_globale; Type: VIEW; Schema: uni; Owner: bitnami
--
CREATE VIEW uni.carriera_valida_globale AS
WITH esami_recenti_globali AS (
SELECT carriera_completa_globale.studente,
carriera_completa_globale.nome,
carriera_completa_globale.corso_laurea,
carriera_completa_globale.anno,
max(carriera_completa_globale.data) AS data_recente
FROM uni.carriera_completa_globale
WHERE (carriera_completa_globale.voto > 17)
GROUP BY carriera_completa_globale.studente, carriera_completa_globale.nome, carriera_completa_globale.corso_laurea, carriera_completa_globale.anno
)
SELECT e.studente,
e.nome,
e.corso_laurea,
e.anno,
e.data_recente,
c.voto
FROM (esami_recenti_globali e
JOIN uni.carriera_completa_globale c ON (((e.studente = c.studente) AND ((e.nome)::text = (c.nome)::text) AND ((e.corso_laurea)::text = (c.corso_laurea)::text) AND (e.data_recente = c.data))));
ALTER TABLE uni.carriera_valida_globale OWNER TO bitnami;
--
-- Name: corso_laurea; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.corso_laurea (
nome character varying NOT NULL,
tipologia character(10) NOT NULL,
segreteria character varying
);
ALTER TABLE uni.corso_laurea OWNER TO bitnami;
--
-- Name: docente; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.docente (
email character varying NOT NULL,
password character varying NOT NULL,
nome character varying(50) NOT NULL,
cognome character varying(50) NOT NULL
);
ALTER TABLE uni.docente OWNER TO bitnami;
--
-- Name: propedeuticita; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.propedeuticita (
corso_is character varying NOT NULL,
codice_is character(3) NOT NULL,
corso_has character varying NOT NULL,
codice_has character(3) NOT NULL
);
ALTER TABLE uni.propedeuticita OWNER TO bitnami;
--
-- Name: segretario; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.segretario (
email character varying NOT NULL,
password character varying NOT NULL,
nome character varying(50) NOT NULL,
cognome character varying(50) NOT NULL,
segreteria character varying
);
ALTER TABLE uni.segretario OWNER TO bitnami;
--
-- Name: segreteria; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.segreteria (
indirizzo character varying NOT NULL
);
ALTER TABLE uni.segreteria OWNER TO bitnami;
--
-- Name: str_studente; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.str_studente (
matricola character(6) NOT NULL,
email character varying NOT NULL,
nome character varying(50) NOT NULL,
cognome character varying(50) NOT NULL,
corso_laurea character varying
);
ALTER TABLE uni.str_studente OWNER TO bitnami;
--
-- Name: studente; Type: TABLE; Schema: uni; Owner: bitnami
--
CREATE TABLE uni.studente (
matricola character(6) NOT NULL,
email character varying NOT NULL,
password character varying NOT NULL,
nome character varying(50) NOT NULL,
cognome character varying(50) NOT NULL,
corso_laurea character varying
);
ALTER TABLE uni.studente OWNER TO bitnami;
--
-- Data for Name: appello; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.appello (corso_laurea, codice, data) FROM stdin;
Informatica 001 2023-06-15
Informatica 001 2023-06-30
Informatica 002 2023-07-10
Informatica 004 2023-07-10
Informatica 004 2023-07-24
Informatica 003 2023-07-17
\.
--
-- Data for Name: corso_laurea; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.corso_laurea (nome, tipologia, segreteria) FROM stdin;
Informatica Triennale Scienze e Tecnologie
Matematica Magistrale Scienze e Tecnologie
\.
--
-- Data for Name: docente; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.docente (email, password, nome, cognome) FROM stdin;
luca.bianchi@example.com 6a4dc9133d5f3b6d9fff778aff361961 Luca Bianchi
giulia.verdi@example.com 6a4dc9133d5f3b6d9fff778aff361961 Giulia Verdi
mario.rossi@example.com 6a4dc9133d5f3b6d9fff778aff361961 Mario Rossi
giovanni.russo@example.com 6a4dc9133d5f3b6d9fff778aff361961 Giovanni Russo
\.
--
-- Data for Name: insegnamento; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.insegnamento (corso_laurea, codice, nome, anno, descrizione, responsabile) FROM stdin;
Informatica 001 Programmazione 1 Corso introduttivo alla programmazione mario.rossi@example.com
Informatica 002 Basi di Dati 2 Intorduzione alle basi di dati luca.bianchi@example.com
Matematica 001 Analisi Matematica 1 Corso di analisi matematica avanzata giulia.verdi@example.com
Informatica 004 Logica Matematica 1 Introduzione alla logica matematica giulia.verdi@example.com
Informatica 003 Matematica del continuo 1 Corso introduttivo di analisi matematica giulia.verdi@example.com
Informatica 005 Architettura degli Elaboratori 1 Corso introduttivo alla architettura degli elaboratori giovanni.russo@example.com
\.
--
-- Data for Name: propedeuticita; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.propedeuticita (corso_is, codice_is, corso_has, codice_has) FROM stdin;
Informatica 001 Informatica 002
\.
--
-- Data for Name: segretario; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.segretario (email, password, nome, cognome, segreteria) FROM stdin;
laura.rosa@example.com 6a4dc9133d5f3b6d9fff778aff361961 Laura Rosa Studi Umanistici
paolo.neri@example.com 6a4dc9133d5f3b6d9fff778aff361961 Paolo Neri Scienze e Tecnologie
\.
--
-- Data for Name: segreteria; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.segreteria (indirizzo) FROM stdin;
Scienze e Tecnologie
Studi Umanistici
\.
--
-- Data for Name: sostiene; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.sostiene (studente, corso_laurea, codice, data, voto) FROM stdin;
789012 Informatica 001 2023-06-30 25
789012 Informatica 002 2023-07-10 27
123456 Informatica 001 2023-06-15 28
123456 Informatica 001 2023-06-30 30
123456 Informatica 002 2023-07-10 \N
123456 Informatica 004 2023-07-10 20
123456 Informatica 003 2023-07-17 27
\.
--
-- Data for Name: str_sostiene; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.str_sostiene (studente, corso_laurea, codice, data, voto) FROM stdin;
\.
--
-- Data for Name: str_studente; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.str_studente (matricola, email, nome, cognome, corso_laurea) FROM stdin;
345678 sara.rossi@example.com Sara Rossi Matematica
\.
--
-- Data for Name: studente; Type: TABLE DATA; Schema: uni; Owner: bitnami
--
COPY uni.studente (matricola, email, password, nome, cognome, corso_laurea) FROM stdin;
789012 marco.bianchi@example.com 6a4dc9133d5f3b6d9fff778aff361961 Marco Bianchi Informatica
123456 giuseppe.verdi@example.com 6a4dc9133d5f3b6d9fff778aff361961 Giuseppe Verdi Informatica
234567 luca.bianchi@example.com 6a4dc9133d5f3b6d9fff778aff361961 Luca Bianchi Informatica
\.
--
-- Name: appello appello_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.appello
ADD CONSTRAINT appello_pkey PRIMARY KEY (corso_laurea, codice, data);
--
-- Name: corso_laurea corso_laurea_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.corso_laurea
ADD CONSTRAINT corso_laurea_pkey PRIMARY KEY (nome);
--
-- Name: docente docente_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.docente
ADD CONSTRAINT docente_pkey PRIMARY KEY (email);
--
-- Name: insegnamento insegnamento_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.insegnamento
ADD CONSTRAINT insegnamento_pkey PRIMARY KEY (corso_laurea, codice);
--
-- Name: propedeuticita propedeuticita_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.propedeuticita
ADD CONSTRAINT propedeuticita_pkey PRIMARY KEY (codice_is, corso_is, corso_has, codice_has);
--
-- Name: segretario segretario_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.segretario
ADD CONSTRAINT segretario_pkey PRIMARY KEY (email);
--
-- Name: segreteria segreteria_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.segreteria
ADD CONSTRAINT segreteria_pkey PRIMARY KEY (indirizzo);
--
-- Name: sostiene sostiene_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.sostiene
ADD CONSTRAINT sostiene_pkey PRIMARY KEY (studente, corso_laurea, codice, data);
--
-- Name: str_sostiene str_sostiene_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.str_sostiene
ADD CONSTRAINT str_sostiene_pkey PRIMARY KEY (studente, corso_laurea, codice, data);
--
-- Name: str_studente str_studente_email_key; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.str_studente
ADD CONSTRAINT str_studente_email_key UNIQUE (email);
--
-- Name: str_studente str_studente_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.str_studente
ADD CONSTRAINT str_studente_pkey PRIMARY KEY (matricola);
--
-- Name: studente studente_email_key; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.studente
ADD CONSTRAINT studente_email_key UNIQUE (email);
--
-- Name: studente studente_pkey; Type: CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.studente
ADD CONSTRAINT studente_pkey PRIMARY KEY (matricola);
--
-- Name: insegnamento gestione_anni_insegnamento; Type: TRIGGER; Schema: uni; Owner: bitnami
--
CREATE TRIGGER gestione_anni_insegnamento BEFORE INSERT ON uni.insegnamento FOR EACH ROW EXECUTE PROCEDURE uni.anno_insegnamento();
--
-- Name: appello gestione_appelli_esami; Type: TRIGGER; Schema: uni; Owner: bitnami
--
CREATE TRIGGER gestione_appelli_esami BEFORE INSERT ON uni.appello FOR EACH ROW EXECUTE PROCEDURE uni.appelli_esami();
--
-- Name: sostiene gestione_iscrizione_esami; Type: TRIGGER; Schema: uni; Owner: bitnami
--
CREATE TRIGGER gestione_iscrizione_esami BEFORE INSERT ON uni.sostiene FOR EACH ROW EXECUTE PROCEDURE uni.iscrizione_esami();
--
-- Name: insegnamento gestione_numero_insegnamenti_docente; Type: TRIGGER; Schema: uni; Owner: bitnami
--
CREATE TRIGGER gestione_numero_insegnamenti_docente AFTER INSERT ON uni.insegnamento FOR EACH ROW EXECUTE PROCEDURE uni.numero_insegnamenti_docente();
--
-- Name: studente storico_studente_carriera; Type: TRIGGER; Schema: uni; Owner: bitnami
--
CREATE TRIGGER storico_studente_carriera BEFORE DELETE ON uni.studente FOR EACH ROW EXECUTE PROCEDURE uni.str_studente_carriera();
--
-- Name: appello appello_insegnamento_fkey; Type: FK CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.appello
ADD CONSTRAINT appello_insegnamento_fkey FOREIGN KEY (corso_laurea, codice) REFERENCES uni.insegnamento(corso_laurea, codice);
--
-- Name: corso_laurea corso_laurea_segreteria_fkey; Type: FK CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.corso_laurea
ADD CONSTRAINT corso_laurea_segreteria_fkey FOREIGN KEY (segreteria) REFERENCES uni.segreteria(indirizzo) ON UPDATE CASCADE;
--
-- Name: propedeuticita has_prop_insegnamento_fkey; Type: FK CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.propedeuticita
ADD CONSTRAINT has_prop_insegnamento_fkey FOREIGN KEY (corso_has, codice_has) REFERENCES uni.insegnamento(corso_laurea, codice);
--
-- Name: insegnamento insegnamento_responsabile_fkey; Type: FK CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.insegnamento
ADD CONSTRAINT insegnamento_responsabile_fkey FOREIGN KEY (responsabile) REFERENCES uni.docente(email) ON UPDATE CASCADE;
--
-- Name: propedeuticita is_prop_insegnamento_fkey; Type: FK CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.propedeuticita
ADD CONSTRAINT is_prop_insegnamento_fkey FOREIGN KEY (corso_is, codice_is) REFERENCES uni.insegnamento(corso_laurea, codice);
--
-- Name: segretario segretario_segreteria_fkey; Type: FK CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.segretario
ADD CONSTRAINT segretario_segreteria_fkey FOREIGN KEY (segreteria) REFERENCES uni.segreteria(indirizzo) ON UPDATE CASCADE;
--
-- Name: sostiene sostiene_appello_fkey; Type: FK CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.sostiene
ADD CONSTRAINT sostiene_appello_fkey FOREIGN KEY (corso_laurea, codice, data) REFERENCES uni.appello(corso_laurea, codice, data);
--
-- Name: studente studente_corso_laurea_fkey; Type: FK CONSTRAINT; Schema: uni; Owner: bitnami
--
ALTER TABLE ONLY uni.studente
ADD CONSTRAINT studente_corso_laurea_fkey FOREIGN KEY (corso_laurea) REFERENCES uni.corso_laurea(nome) ON UPDATE CASCADE;
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+583
View File
@@ -0,0 +1,583 @@
-- Downloaded from: https://github.com/heydabop/rustyz/blob/f26ef98d6439f7cc046125ab75ecd2bc7b0ae3b7/schema.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.4 (Debian 12.4-3)
-- Dumped by pg_dump version 12.4 (Debian 12.4-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;
--
-- Name: online_status; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.online_status AS ENUM (
'dnd',
'idle',
'invisible',
'offline',
'online'
);
--
-- Name: shipment_carrier; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.shipment_carrier AS ENUM (
'fedex',
'ups',
'usps'
);
--
-- Name: shipment_tracking_status; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.shipment_tracking_status AS ENUM (
'unknown',
'pre_transit',
'transit',
'delivered',
'returned',
'failure'
);
--
-- Name: row_update_date(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.row_update_date() RETURNS trigger
LANGUAGE plpgsql
AS $$
begin
new.update_date = now();
return new;
end;
$$;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: bot_start; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.bot_start (
id integer NOT NULL,
create_date timestamp with time zone DEFAULT now() NOT NULL,
update_date timestamp with time zone DEFAULT now() NOT NULL,
clean_shutdown boolean
);
--
-- Name: bot_start_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.bot_start_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: bot_start_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.bot_start_id_seq OWNED BY public.bot_start.id;
--
-- Name: command; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.command (
id integer NOT NULL,
create_date timestamp with time zone DEFAULT now() NOT NULL,
author_id bigint NOT NULL,
channel_id bigint NOT NULL,
guild_id bigint,
name character varying(32) NOT NULL,
options jsonb
);
--
-- Name: command_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.command_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: command_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.command_id_seq OWNED BY public.command.id;
--
-- Name: message; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.message (
id bigint NOT NULL,
create_date timestamp with time zone DEFAULT now() NOT NULL,
discord_id numeric NOT NULL,
author_id bigint NOT NULL,
channel_id bigint NOT NULL,
guild_id bigint,
content text,
update_date timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: message_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.message_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.message_id_seq OWNED BY public.message.id;
--
-- Name: playtime_button; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.playtime_button (
id integer NOT NULL,
create_date timestamp with time zone DEFAULT now() NOT NULL,
author_id bigint NOT NULL,
user_ids bigint[] NOT NULL,
username character varying(32),
start_date timestamp with time zone,
end_date timestamp with time zone NOT NULL,
start_offset integer NOT NULL
);
--
-- Name: playtime_button_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.playtime_button_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: playtime_button_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.playtime_button_id_seq OWNED BY public.playtime_button.id;
--
-- Name: shipment; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.shipment (
id integer NOT NULL,
create_date timestamp with time zone DEFAULT now() NOT NULL,
update_date timestamp with time zone DEFAULT now() NOT NULL,
carrier public.shipment_carrier NOT NULL,
tracking_number character varying(100) NOT NULL,
author_id bigint NOT NULL,
channel_id bigint NOT NULL,
status public.shipment_tracking_status NOT NULL,
comment character varying(50)
);
--
-- Name: shipment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.shipment_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: shipment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.shipment_id_seq OWNED BY public.shipment.id;
--
-- Name: user_karma; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.user_karma (
guild_id bigint NOT NULL,
user_id bigint NOT NULL,
karma integer NOT NULL
);
--
-- Name: user_presence; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.user_presence (
id bigint NOT NULL,
create_date timestamp with time zone DEFAULT now() NOT NULL,
user_id bigint NOT NULL,
status public.online_status NOT NULL,
game_name character varying(512)
);
--
-- Name: user_presence_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.user_presence_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: user_presence_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.user_presence_id_seq OWNED BY public.user_presence.id;
--
-- Name: vote; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.vote (
id integer NOT NULL,
create_date timestamp with time zone DEFAULT now() NOT NULL,
guild_id bigint NOT NULL,
voter_id bigint NOT NULL,
votee_id bigint NOT NULL,
is_upvote boolean NOT NULL
);
--
-- Name: vote_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.vote_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: vote_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.vote_id_seq OWNED BY public.vote.id;
--
-- Name: bot_start id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.bot_start ALTER COLUMN id SET DEFAULT nextval('public.bot_start_id_seq'::regclass);
--
-- Name: command id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.command ALTER COLUMN id SET DEFAULT nextval('public.command_id_seq'::regclass);
--
-- Name: message id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.message ALTER COLUMN id SET DEFAULT nextval('public.message_id_seq'::regclass);
--
-- Name: playtime_button id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.playtime_button ALTER COLUMN id SET DEFAULT nextval('public.playtime_button_id_seq'::regclass);
--
-- Name: shipment id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.shipment ALTER COLUMN id SET DEFAULT nextval('public.shipment_id_seq'::regclass);
--
-- Name: user_presence id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_presence ALTER COLUMN id SET DEFAULT nextval('public.user_presence_id_seq'::regclass);
--
-- Name: vote id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.vote ALTER COLUMN id SET DEFAULT nextval('public.vote_id_seq'::regclass);
--
-- Name: bot_start bot_start_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.bot_start
ADD CONSTRAINT bot_start_pkey PRIMARY KEY (id);
--
-- Name: command command_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.command
ADD CONSTRAINT command_pkey PRIMARY KEY (id);
--
-- Name: message message_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.message
ADD CONSTRAINT message_pkey PRIMARY KEY (id);
--
-- Name: shipment shipment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.shipment
ADD CONSTRAINT shipment_pkey PRIMARY KEY (id);
--
-- Name: shipment shipment_uk_carrier_number; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.shipment
ADD CONSTRAINT shipment_uk_carrier_number UNIQUE (carrier, tracking_number);
--
-- Name: user_karma user_karma_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_karma
ADD CONSTRAINT user_karma_pkey PRIMARY KEY (guild_id, user_id);
--
-- Name: user_presence user_presence_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_presence
ADD CONSTRAINT user_presence_pkey PRIMARY KEY (id);
--
-- Name: vote vote_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.vote
ADD CONSTRAINT vote_pkey PRIMARY KEY (id);
--
-- Name: user_karma_guild_id_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX user_karma_guild_id_idx ON public.user_karma USING btree (guild_id);
--
-- Name: vote_voter_id_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX vote_voter_id_idx ON public.vote USING btree (voter_id);
--
-- Name: bot_start bot_start_row_update_date; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER bot_start_row_update_date BEFORE UPDATE ON public.bot_start FOR EACH ROW EXECUTE FUNCTION public.row_update_date();
--
-- Name: message message_row_update_date; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER message_row_update_date BEFORE UPDATE ON public.message FOR EACH ROW EXECUTE FUNCTION public.row_update_date();
--
-- Name: shipment shipment_row_update_date; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER shipment_row_update_date BEFORE UPDATE ON public.shipment FOR EACH ROW EXECUTE FUNCTION public.row_update_date();
--
-- Name: TABLE bot_start; Type: ACL; Schema: public; Owner: -
--
GRANT SELECT,INSERT,UPDATE ON TABLE public.bot_start TO rustyz;
--
-- Name: SEQUENCE bot_start_id_seq; Type: ACL; Schema: public; Owner: -
--
GRANT USAGE ON SEQUENCE public.bot_start_id_seq TO rustyz;
--
-- Name: TABLE command; Type: ACL; Schema: public; Owner: -
--
GRANT SELECT,INSERT ON TABLE public.command TO rustyz;
--
-- Name: SEQUENCE command_id_seq; Type: ACL; Schema: public; Owner: -
--
GRANT USAGE ON SEQUENCE public.command_id_seq TO rustyz;
--
-- Name: TABLE message; Type: ACL; Schema: public; Owner: -
--
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.message TO rustyz;
--
-- Name: SEQUENCE message_id_seq; Type: ACL; Schema: public; Owner: -
--
GRANT USAGE ON SEQUENCE public.message_id_seq TO rustyz;
--
-- Name: TABLE playtime_button; Type: ACL; Schema: public; Owner: -
--
GRANT SELECT,INSERT,UPDATE ON TABLE public.playtime_button TO rustyz;
--
-- Name: SEQUENCE playtime_button_id_seq; Type: ACL; Schema: public; Owner: -
--
GRANT USAGE ON SEQUENCE public.playtime_button_id_seq TO rustyz;
--
-- Name: TABLE shipment; Type: ACL; Schema: public; Owner: -
--
GRANT SELECT,INSERT,UPDATE ON TABLE public.shipment TO rustyz;
--
-- Name: SEQUENCE shipment_id_seq; Type: ACL; Schema: public; Owner: -
--
GRANT USAGE ON SEQUENCE public.shipment_id_seq TO rustyz;
--
-- Name: TABLE user_karma; Type: ACL; Schema: public; Owner: -
--
GRANT SELECT,INSERT,UPDATE ON TABLE public.user_karma TO rustyz;
--
-- Name: TABLE user_presence; Type: ACL; Schema: public; Owner: -
--
GRANT SELECT,INSERT ON TABLE public.user_presence TO rustyz;
--
-- Name: SEQUENCE user_presence_id_seq; Type: ACL; Schema: public; Owner: -
--
GRANT USAGE ON SEQUENCE public.user_presence_id_seq TO rustyz;
--
-- Name: TABLE vote; Type: ACL; Schema: public; Owner: -
--
GRANT SELECT,INSERT,UPDATE ON TABLE public.vote TO rustyz;
--
-- Name: SEQUENCE vote_id_seq; Type: ACL; Schema: public; Owner: -
--
GRANT USAGE ON SEQUENCE public.vote_id_seq TO rustyz;
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,645 @@
-- Downloaded from: https://github.com/ii-habibi/Dental-Clinic/blob/214da734250e375ec01f7aef4fca580af37db0bb/Database_Schema.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 17.2
-- Dumped by pg_dump version 17.2
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;
--
-- Name: update_timestamp(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.update_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$;
ALTER FUNCTION public.update_timestamp() OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: admins; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.admins (
id integer NOT NULL,
username character varying(50) NOT NULL,
password character varying(255) NOT NULL,
is_super_admin boolean DEFAULT false,
name character varying(20) NOT NULL
);
ALTER TABLE public.admins OWNER TO postgres;
--
-- Name: admins_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.admins_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.admins_id_seq OWNER TO postgres;
--
-- Name: admins_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.admins_id_seq OWNED BY public.admins.id;
--
-- Name: appointment; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.appointment (
appointment_id integer NOT NULL,
patient_id integer,
doctor_id integer,
appointment_date date,
appointment_time time without time zone,
treatment_type character varying(255),
status character varying(50),
visit_type character varying(50),
notes text,
payment_status character varying(50),
amount numeric(10,2),
payment_date timestamp without time zone,
payment_message text
);
ALTER TABLE public.appointment OWNER TO postgres;
--
-- Name: appointment_appointment_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.appointment_appointment_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.appointment_appointment_id_seq OWNER TO postgres;
--
-- Name: appointment_appointment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.appointment_appointment_id_seq OWNED BY public.appointment.appointment_id;
--
-- Name: audit_logs; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.audit_logs (
id integer NOT NULL,
admin_id integer NOT NULL,
appointment_id integer,
action_type character varying(50),
old_value jsonb,
new_value jsonb,
created_at timestamp without time zone DEFAULT now(),
expense_id integer,
income_id integer
);
ALTER TABLE public.audit_logs OWNER TO postgres;
--
-- Name: audit_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.audit_logs_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.audit_logs_id_seq OWNER TO postgres;
--
-- Name: audit_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.audit_logs_id_seq OWNED BY public.audit_logs.id;
--
-- Name: blog; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.blog (
blog_id integer NOT NULL,
title character varying(255) NOT NULL,
content text,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
author character varying(255)
);
ALTER TABLE public.blog OWNER TO postgres;
--
-- Name: blog_blog_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.blog_blog_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.blog_blog_id_seq OWNER TO postgres;
--
-- Name: blog_blog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.blog_blog_id_seq OWNED BY public.blog.blog_id;
--
-- Name: doctors; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.doctors (
id integer NOT NULL,
name character varying(100) NOT NULL,
qualification character varying(255) NOT NULL,
expertise text NOT NULL,
photo character varying(255),
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.doctors OWNER TO postgres;
--
-- Name: doctors_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.doctors_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.doctors_id_seq OWNER TO postgres;
--
-- Name: doctors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.doctors_id_seq OWNED BY public.doctors.id;
--
-- Name: expenses; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.expenses (
id integer NOT NULL,
doctor_id integer,
amount numeric(10,2) NOT NULL,
type character varying(50) NOT NULL,
description text,
date timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.expenses OWNER TO postgres;
--
-- Name: expenses_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.expenses_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.expenses_id_seq OWNER TO postgres;
--
-- Name: expenses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.expenses_id_seq OWNED BY public.expenses.id;
--
-- Name: incomes; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.incomes (
id integer NOT NULL,
description character varying(255) NOT NULL,
amount numeric(10,2) NOT NULL,
date date NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.incomes OWNER TO postgres;
--
-- Name: incomes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.incomes_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.incomes_id_seq OWNER TO postgres;
--
-- Name: incomes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.incomes_id_seq OWNED BY public.incomes.id;
--
-- Name: patients; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.patients (
patient_id integer NOT NULL,
name character varying(255),
email character varying(255),
phone character varying(20),
age integer,
gender character varying(10),
address character varying(200)
);
ALTER TABLE public.patients OWNER TO postgres;
--
-- Name: patients_patient_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.patients_patient_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.patients_patient_id_seq OWNER TO postgres;
--
-- Name: patients_patient_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.patients_patient_id_seq OWNED BY public.patients.patient_id;
--
-- Name: services; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.services (
service_id integer NOT NULL,
name character varying(100) NOT NULL,
description text,
price numeric(10,2) NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.services OWNER TO postgres;
--
-- Name: services_service_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.services_service_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.services_service_id_seq OWNER TO postgres;
--
-- Name: services_service_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.services_service_id_seq OWNED BY public.services.service_id;
--
-- Name: admins id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admins ALTER COLUMN id SET DEFAULT nextval('public.admins_id_seq'::regclass);
--
-- Name: appointment appointment_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.appointment ALTER COLUMN appointment_id SET DEFAULT nextval('public.appointment_appointment_id_seq'::regclass);
--
-- Name: audit_logs id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.audit_logs ALTER COLUMN id SET DEFAULT nextval('public.audit_logs_id_seq'::regclass);
--
-- Name: blog blog_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.blog ALTER COLUMN blog_id SET DEFAULT nextval('public.blog_blog_id_seq'::regclass);
--
-- Name: doctors id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.doctors ALTER COLUMN id SET DEFAULT nextval('public.doctors_id_seq'::regclass);
--
-- Name: expenses id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.expenses ALTER COLUMN id SET DEFAULT nextval('public.expenses_id_seq'::regclass);
--
-- Name: incomes id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.incomes ALTER COLUMN id SET DEFAULT nextval('public.incomes_id_seq'::regclass);
--
-- Name: patients patient_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.patients ALTER COLUMN patient_id SET DEFAULT nextval('public.patients_patient_id_seq'::regclass);
--
-- Name: services service_id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.services ALTER COLUMN service_id SET DEFAULT nextval('public.services_service_id_seq'::regclass);
--
-- Name: admins admins_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admins
ADD CONSTRAINT admins_pkey PRIMARY KEY (id);
--
-- Name: admins admins_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admins
ADD CONSTRAINT admins_username_key UNIQUE (username);
--
-- Name: appointment appointment_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.appointment
ADD CONSTRAINT appointment_pkey PRIMARY KEY (appointment_id);
--
-- Name: audit_logs audit_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.audit_logs
ADD CONSTRAINT audit_logs_pkey PRIMARY KEY (id);
--
-- Name: blog blog_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.blog
ADD CONSTRAINT blog_pkey PRIMARY KEY (blog_id);
--
-- Name: doctors doctors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.doctors
ADD CONSTRAINT doctors_pkey PRIMARY KEY (id);
--
-- Name: expenses expenses_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.expenses
ADD CONSTRAINT expenses_pkey PRIMARY KEY (id);
--
-- Name: incomes incomes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.incomes
ADD CONSTRAINT incomes_pkey PRIMARY KEY (id);
--
-- Name: patients patients_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.patients
ADD CONSTRAINT patients_email_key UNIQUE (email);
--
-- Name: patients patients_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.patients
ADD CONSTRAINT patients_pkey PRIMARY KEY (patient_id);
--
-- Name: services services_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.services
ADD CONSTRAINT services_pkey PRIMARY KEY (service_id);
--
-- Name: idx_appointment_payment_date; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_appointment_payment_date ON public.appointment USING btree (payment_date);
--
-- Name: idx_expenses_date; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_expenses_date ON public.expenses USING btree (date);
--
-- Name: idx_expenses_type; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_expenses_type ON public.expenses USING btree (type);
--
-- Name: idx_incomes_amount; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_incomes_amount ON public.incomes USING btree (amount);
--
-- Name: idx_incomes_date; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX idx_incomes_date ON public.incomes USING btree (date);
--
-- Name: incomes set_timestamp_incomes; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER set_timestamp_incomes BEFORE UPDATE ON public.incomes FOR EACH ROW EXECUTE FUNCTION public.update_timestamp();
--
-- Name: services set_timestamp_services; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER set_timestamp_services BEFORE UPDATE ON public.services FOR EACH ROW EXECUTE FUNCTION public.update_timestamp();
--
-- Name: appointment appointment_patient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.appointment
ADD CONSTRAINT appointment_patient_id_fkey FOREIGN KEY (patient_id) REFERENCES public.patients(patient_id);
--
-- Name: audit_logs audit_logs_admin_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.audit_logs
ADD CONSTRAINT audit_logs_admin_id_fkey FOREIGN KEY (admin_id) REFERENCES public.admins(id);
--
-- Name: audit_logs audit_logs_appointment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.audit_logs
ADD CONSTRAINT audit_logs_appointment_id_fkey FOREIGN KEY (appointment_id) REFERENCES public.appointment(appointment_id) ON DELETE SET NULL;
--
-- Name: audit_logs audit_logs_expense_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.audit_logs
ADD CONSTRAINT audit_logs_expense_id_fkey FOREIGN KEY (expense_id) REFERENCES public.expenses(id);
--
-- Name: audit_logs audit_logs_income_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.audit_logs
ADD CONSTRAINT audit_logs_income_id_fkey FOREIGN KEY (income_id) REFERENCES public.incomes(id);
--
-- Name: expenses expenses_doctor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.expenses
ADD CONSTRAINT expenses_doctor_id_fkey FOREIGN KEY (doctor_id) REFERENCES public.doctors(id) ON DELETE SET NULL;
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,329 @@
-- Downloaded from: https://github.com/joec05/social-media-app-pgsql/blob/a25959893494eaffd03deac61dabb08582cabf56/users_chats.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16rc1
-- Dumped by pg_dump version 16rc1
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;
--
-- Name: group_messages; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA group_messages;
ALTER SCHEMA group_messages OWNER to postgres;
--
-- Name: group_profile; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA group_profile;
ALTER SCHEMA group_profile OWNER to postgres;
--
-- Name: private_messages; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA private_messages;
ALTER SCHEMA private_messages OWNER to postgres;
--
-- Name: users_chats; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA users_chats;
ALTER SCHEMA users_chats OWNER to postgres;
--
-- Name: dblink; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
--
-- Name: EXTENSION dblink; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION dblink IS 'connect to other PostgreSQL databases from within a database';
--
-- Name: fetch_user_chats(text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_user_chats(currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(chat_data json)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select row_to_json(f) from users_chats.chats_history as f
where f.user_id = $1 and f.deleted = false and (f.recipient = '' or
(f.recipient != '' and not is_blocked_user($1, f.recipient, username, ip, port, password)
and not is_blocked_user(f.recipient, $1, username, ip, port, password)
and is_exists_user($1, f.recipient, username, ip, port, password)))
offset $2 limit $3;
end;
$_$;
ALTER FUNCTION public.fetch_user_chats(currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: is_blocked_user(text, text, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.is_blocked_user(checkingid text, checkedid text, username text, ip text, port integer, password text) RETURNS boolean
LANGUAGE plpgsql
AS $_$
declare
res bool;
users_profiles_path text := 'dbname=users_profiles user='||username||' hostaddr='||ip||' port='||port||' password='||password;
begin
if checkingid = checkedid then return false; end if;
select exists (
select * from dblink(users_profiles_path, 'select * from blocked_users.block_history') as b(user_id text, blocked_id text)
where b.user_id = $1 and b.blocked_id = $2
) into res;
return res;
end;
$_$;
ALTER FUNCTION public.is_blocked_user(checkingid text, checkedid text, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: is_exists_user(text, text, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.is_exists_user(checkingid text, checkedid text, username text, ip text, port integer, password text) RETURNS boolean
LANGUAGE plpgsql
AS $_$
declare
res bool;
users_profiles_path text := 'dbname=users_profiles user='||username||' hostaddr='||ip||' port='||port||' password='||password;
begin
if checkingid = checkedid then return true; end if;
select exists (
select * from dblink(users_profiles_path, 'select user_id, deleted, suspended from basic_data.user_profile') as pr(user_id text, deleted bool, suspended bool)
where pr.user_id = $2 and pr.deleted = false and pr.suspended = false
) into res;
return res;
end;
$_$;
ALTER FUNCTION public.is_exists_user(checkingid text, checkedid text, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: is_muted_user(text, text, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.is_muted_user(checkingid text, checkedid text, username text, ip text, port integer, password text) RETURNS boolean
LANGUAGE plpgsql
AS $_$
declare
res bool;
users_profiles_path text := 'dbname=users_profiles user='||username||' hostaddr='||ip||' port='||port||' password='||password;
begin
if checkingid = checkedid then return false; end if;
select exists (
select * from dblink(users_profiles_path, 'select * from muted_users.mute_history') as m(user_id text, muted_id text)
where m.user_id = $1 and m.muted_id = $2
) into res;
return res;
end;
$_$;
ALTER FUNCTION public.is_muted_user(checkingid text, checkedid text, username text, ip text, port integer, password text) OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: messages_history; Type: TABLE; Schema: group_messages; Owner: postgres
--
CREATE TABLE group_messages.messages_history (
chat_id text NOT NULL,
message_id text NOT NULL,
type text NOT NULL,
content text NOT NULL,
sender text NOT NULL,
upload_time text NOT NULL,
medias_datas text NOT NULL,
deleted_list text[] NOT NULL
);
ALTER TABLE group_messages.messages_history OWNER TO postgres;
--
-- Name: group_info; Type: TABLE; Schema: group_profile; Owner: postgres
--
CREATE TABLE group_profile.group_info (
chat_id text NOT NULL,
name text NOT NULL,
profile_pic_link text NOT NULL,
description text NOT NULL,
members text[] NOT NULL
);
ALTER TABLE group_profile.group_info OWNER TO postgres;
--
-- Name: messages_history; Type: TABLE; Schema: private_messages; Owner: postgres
--
CREATE TABLE private_messages.messages_history (
chat_id text NOT NULL,
message_id text NOT NULL,
type text NOT NULL,
content text NOT NULL,
sender text NOT NULL,
upload_time text NOT NULL,
medias_datas text NOT NULL,
deleted_list text[] NOT NULL
);
ALTER TABLE private_messages.messages_history OWNER TO postgres;
--
-- Name: chats_history; Type: TABLE; Schema: users_chats; Owner: postgres
--
CREATE TABLE users_chats.chats_history (
user_id text NOT NULL,
chat_id text NOT NULL,
type text NOT NULL,
recipient text NOT NULL,
deleted boolean NOT NULL
);
ALTER TABLE users_chats.chats_history OWNER TO postgres;
--
-- Data for Name: messages_history; Type: TABLE DATA; Schema: group_messages; Owner: postgres
--
COPY group_messages.messages_history (chat_id, message_id, type, content, sender, upload_time, medias_datas, deleted_list) FROM stdin;
\.
--
-- Data for Name: group_info; Type: TABLE DATA; Schema: group_profile; Owner: postgres
--
COPY group_profile.group_info (chat_id, name, profile_pic_link, description, members) FROM stdin;
\.
--
-- Data for Name: messages_history; Type: TABLE DATA; Schema: private_messages; Owner: postgres
--
COPY private_messages.messages_history (chat_id, message_id, type, content, sender, upload_time, medias_datas, deleted_list) FROM stdin;
\.
--
-- Data for Name: chats_history; Type: TABLE DATA; Schema: users_chats; Owner: postgres
--
COPY users_chats.chats_history (user_id, chat_id, type, recipient, deleted) FROM stdin;
\.
--
-- Name: messages_history group_messages_constraint; Type: CONSTRAINT; Schema: group_messages; Owner: postgres
--
ALTER TABLE ONLY group_messages.messages_history
ADD CONSTRAINT group_messages_constraint UNIQUE (message_id);
--
-- Name: messages_history messages_history_pkey; Type: CONSTRAINT; Schema: group_messages; Owner: postgres
--
ALTER TABLE ONLY group_messages.messages_history
ADD CONSTRAINT messages_history_pkey PRIMARY KEY (message_id);
--
-- Name: group_info group_info_constraints; Type: CONSTRAINT; Schema: group_profile; Owner: postgres
--
ALTER TABLE ONLY group_profile.group_info
ADD CONSTRAINT group_info_constraints UNIQUE (chat_id);
--
-- Name: group_info group_info_pkey; Type: CONSTRAINT; Schema: group_profile; Owner: postgres
--
ALTER TABLE ONLY group_profile.group_info
ADD CONSTRAINT group_info_pkey PRIMARY KEY (chat_id);
--
-- Name: messages_history messages_history_pkey; Type: CONSTRAINT; Schema: private_messages; Owner: postgres
--
ALTER TABLE ONLY private_messages.messages_history
ADD CONSTRAINT messages_history_pkey PRIMARY KEY (message_id);
--
-- Name: messages_history private_messages_constraints; Type: CONSTRAINT; Schema: private_messages; Owner: postgres
--
ALTER TABLE ONLY private_messages.messages_history
ADD CONSTRAINT private_messages_constraints UNIQUE (message_id);
--
-- Name: chats_history chats_constraint; Type: CONSTRAINT; Schema: users_chats; Owner: postgres
--
ALTER TABLE ONLY users_chats.chats_history
ADD CONSTRAINT chats_constraint UNIQUE (user_id, chat_id);
--
-- Name: chats_history chats_primary_key; Type: CONSTRAINT; Schema: users_chats; Owner: postgres
--
ALTER TABLE ONLY users_chats.chats_history
ADD CONSTRAINT chats_primary_key PRIMARY KEY (user_id, chat_id);
--
-- PostgreSQL database dump complete
--
+456
View File
@@ -0,0 +1,456 @@
-- Downloaded from: https://github.com/julesd7/collatask/blob/659e477af286721943425883fd618038bfa94ea9/structure.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.4
-- Dumped by pg_dump version 16.8 (Homebrew)
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;
--
-- Name: assign_user_to_project(integer, integer, character varying); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.assign_user_to_project(p_user_id integer, p_project_id integer, p_role character varying DEFAULT 'member'::character varying) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
INSERT INTO project_assignments (user_id, project_id, role)
VALUES (p_user_id, p_project_id, p_role)
ON CONFLICT (user_id, project_id) DO NOTHING; -- Ignore si l'utilisateur est déjà assigné
END;
$$;
--
-- Name: create_default_boards(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.create_default_boards() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
INSERT INTO boards (project_id, title) VALUES (NEW.id, 'To Do');
INSERT INTO boards (project_id, title) VALUES (NEW.id, 'In Progress');
INSERT INTO boards (project_id, title) VALUES (NEW.id, 'Completed');
RETURN NEW;
END;
$$;
--
-- Name: set_deleted_user(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.set_deleted_user() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE messages
SET sender = 'DeletedUser'
WHERE sender = OLD.username;
RETURN OLD;
END;
$$;
--
-- Name: update_board_timestamp(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_board_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP; -- Met à jour le champ updated_at à l'heure actuelle
RETURN NEW;
END;
$$;
--
-- Name: update_card_last_change(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_card_last_change() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.last_change = CURRENT_TIMESTAMP; -- Met à jour le champ last_change à l'heure actuelle
RETURN NEW;
END;
$$;
--
-- Name: update_project_timestamp(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_project_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE projects
SET updated_at = CURRENT_TIMESTAMP
WHERE id = NEW.project_id;
RETURN NEW;
END;
$$;
--
-- Name: update_task_timestamp(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_task_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP; -- Met à jour le champ updated_at à l'heure actuelle
RETURN NEW;
END;
$$;
--
-- Name: update_timestamp(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP; -- Met à jour le champ updated_at à l'heure actuelle
RETURN NEW;
END;
$$;
--
-- Name: update_updated_at(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_updated_at() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: boards; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.boards (
id uuid DEFAULT gen_random_uuid() NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
title character varying(255),
project_id uuid
);
--
-- Name: cards; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.cards (
id uuid DEFAULT gen_random_uuid() NOT NULL,
title character varying(100) NOT NULL,
description text,
start_date date,
end_date date,
last_change timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
board_id uuid,
project_id uuid,
assignees_ids uuid[],
priority character varying(2),
CONSTRAINT cards_priority_check CHECK (((priority)::text = ANY ((ARRAY['P0'::character varying, 'P1'::character varying, 'P2'::character varying, 'P3'::character varying])::text[])))
);
--
-- Name: cards_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.cards_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: messages; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.messages (
id uuid DEFAULT gen_random_uuid() NOT NULL,
message text NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
room uuid NOT NULL,
sender text NOT NULL
);
--
-- Name: project_assignments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.project_assignments (
id uuid DEFAULT gen_random_uuid() NOT NULL,
role character varying(20) DEFAULT 'viewer'::character varying,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
user_id uuid NOT NULL,
project_id uuid NOT NULL
);
--
-- Name: projects; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.projects (
id uuid DEFAULT gen_random_uuid() NOT NULL,
title character varying(100) NOT NULL,
description text,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
owner_id uuid
);
--
-- Name: tasks; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.tasks (
id uuid DEFAULT gen_random_uuid() NOT NULL,
title character varying(100) NOT NULL,
description text,
status character varying(20) DEFAULT 'pending'::character varying,
board_id integer NOT NULL,
assigned_to integer,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users (
id uuid DEFAULT gen_random_uuid() NOT NULL,
username character varying(50) NOT NULL,
email character varying(100) NOT NULL,
password character varying(255),
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
verified boolean DEFAULT false,
verification_token character varying(255),
reset_token character varying(255),
last_connection timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: boards boards_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.boards
ADD CONSTRAINT boards_pkey PRIMARY KEY (id);
--
-- Name: cards cards_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.cards
ADD CONSTRAINT cards_pkey PRIMARY KEY (id);
--
-- Name: project_assignments project_assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_assignments
ADD CONSTRAINT project_assignments_pkey PRIMARY KEY (id);
--
-- Name: projects projects_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.projects
ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
--
-- Name: tasks tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.tasks
ADD CONSTRAINT tasks_pkey PRIMARY KEY (id);
--
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_email_key UNIQUE (email);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_username_key UNIQUE (username);
--
-- Name: project_assignments set_updated_at; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER set_updated_at BEFORE UPDATE ON public.project_assignments FOR EACH ROW EXECUTE FUNCTION public.update_updated_at();
--
-- Name: projects trigger_create_default_boards; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER trigger_create_default_boards AFTER INSERT ON public.projects FOR EACH ROW EXECUTE FUNCTION public.create_default_boards();
--
-- Name: boards trigger_update_board_timestamp; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER trigger_update_board_timestamp BEFORE UPDATE ON public.boards FOR EACH ROW EXECUTE FUNCTION public.update_board_timestamp();
--
-- Name: cards trigger_update_card_last_change; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER trigger_update_card_last_change BEFORE UPDATE ON public.cards FOR EACH ROW EXECUTE FUNCTION public.update_card_last_change();
--
-- Name: boards trigger_update_project_on_board_change; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER trigger_update_project_on_board_change AFTER INSERT OR DELETE OR UPDATE ON public.boards FOR EACH ROW EXECUTE FUNCTION public.update_project_timestamp();
--
-- Name: cards trigger_update_project_on_card_change; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER trigger_update_project_on_card_change AFTER INSERT OR DELETE OR UPDATE ON public.cards FOR EACH ROW EXECUTE FUNCTION public.update_project_timestamp();
--
-- Name: tasks trigger_update_task_timestamp; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER trigger_update_task_timestamp BEFORE UPDATE ON public.tasks FOR EACH ROW EXECUTE FUNCTION public.update_task_timestamp();
--
-- Name: users user_deletion_trigger; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER user_deletion_trigger BEFORE DELETE ON public.users FOR EACH ROW EXECUTE FUNCTION public.set_deleted_user();
--
-- Name: cards fk_board_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.cards
ADD CONSTRAINT fk_board_id FOREIGN KEY (board_id) REFERENCES public.boards(id) ON DELETE CASCADE;
--
-- Name: projects fk_owner_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.projects
ADD CONSTRAINT fk_owner_id FOREIGN KEY (owner_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: project_assignments fk_project; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_assignments
ADD CONSTRAINT fk_project FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
--
-- Name: project_assignments fk_project_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_assignments
ADD CONSTRAINT fk_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
--
-- Name: boards fk_project_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.boards
ADD CONSTRAINT fk_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
--
-- Name: cards fk_project_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.cards
ADD CONSTRAINT fk_project_id FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
--
-- Name: project_assignments fk_user; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_assignments
ADD CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,608 @@
-- Downloaded from: https://github.com/jwalit21/BitmapJoinDatabaseEngine/blob/d8bb2343fd89a88a6eb88503b6ccd308a2bc9cd3/R_S.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.9 (Debian 14.9-1.pgdg120+1)
-- Dumped by pg_dump version 14.9 (Debian 14.9-1.pgdg120+1)
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;
--
-- Name: plpython3u; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS plpython3u WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpython3u; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpython3u IS 'PL/Python3U untrusted procedural language';
--
-- Name: random_int(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.random_int() RETURNS integer
LANGUAGE plpgsql
AS $$
BEGIN
RETURN floor(random() * 5 + 1)::INTEGER;
END;
$$;
ALTER FUNCTION public.random_int() OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: r; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.r (
a1 integer,
a2 integer,
a3 integer,
a4 integer,
ann character varying(10),
i integer NOT NULL
);
ALTER TABLE public.r OWNER TO postgres;
--
-- Name: r_i_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.r_i_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.r_i_seq OWNER TO postgres;
--
-- Name: r_i_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.r_i_seq OWNED BY public.r.i;
--
-- Name: s; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.s (
b1 integer,
b2 integer,
b3 integer,
b4 integer,
ann character varying(10),
i integer NOT NULL
);
ALTER TABLE public.s OWNER TO postgres;
--
-- Name: s_i_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.s_i_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.s_i_seq OWNER TO postgres;
--
-- Name: s_i_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.s_i_seq OWNED BY public.s.i;
--
-- Name: r i; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.r ALTER COLUMN i SET DEFAULT nextval('public.r_i_seq'::regclass);
--
-- Name: s i; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.s ALTER COLUMN i SET DEFAULT nextval('public.s_i_seq'::regclass);
--
-- Data for Name: r; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.r (a1, a2, a3, a4, ann, i) FROM stdin;
1 5 4 4 R1 1
3 2 2 5 R2 2
1 5 3 2 R3 3
1 3 2 4 R4 4
4 4 4 2 R5 5
2 3 4 4 R6 6
2 3 1 3 R7 7
4 1 2 4 R8 8
3 5 4 2 R9 9
2 4 2 5 R10 10
4 5 1 1 R11 11
2 5 3 3 R12 12
3 5 3 2 R13 13
3 2 3 3 R14 14
1 3 2 2 R15 15
2 2 4 4 R16 16
1 2 5 4 R17 17
4 1 5 4 R18 18
4 1 4 5 R19 19
5 2 3 1 R20 20
3 5 4 1 R21 21
2 2 3 4 R22 22
2 1 3 1 R23 23
1 4 1 2 R24 24
2 2 5 3 R25 25
3 5 3 1 R26 26
4 2 3 1 R27 27
2 1 2 5 R28 28
5 5 4 5 R29 29
1 4 4 4 R30 30
3 1 3 3 R31 31
2 5 4 5 R32 32
2 4 5 5 R33 33
2 3 4 3 R34 34
2 2 3 3 R35 35
2 3 4 4 R36 36
4 2 5 2 R37 37
4 5 5 5 R38 38
1 2 4 1 R39 39
2 4 3 5 R40 40
5 5 5 2 R41 41
5 5 1 1 R42 42
3 4 3 1 R43 43
5 2 2 4 R44 44
4 1 5 1 R45 45
5 2 1 4 R46 46
5 1 3 3 R47 47
3 3 2 1 R48 48
1 2 1 2 R49 49
5 1 3 3 R50 50
1 3 3 2 R51 51
3 4 4 4 R52 52
1 3 5 3 R53 53
2 2 5 2 R54 54
1 4 3 2 R55 55
2 2 1 4 R56 56
4 1 3 4 R57 57
2 1 2 1 R58 58
3 3 3 5 R59 59
3 3 3 4 R60 60
2 1 1 5 R61 61
2 4 1 4 R62 62
3 2 5 2 R63 63
1 5 1 3 R64 64
4 5 3 5 R65 65
5 1 1 4 R66 66
2 1 1 4 R67 67
3 2 1 5 R68 68
5 2 5 3 R69 69
1 3 4 4 R70 70
3 3 2 4 R71 71
3 3 1 4 R72 72
2 3 2 5 R73 73
5 2 3 4 R74 74
2 2 1 1 R75 75
1 4 1 1 R76 76
4 4 1 1 R77 77
2 2 4 1 R78 78
1 1 4 3 R79 79
2 3 1 4 R80 80
3 2 4 1 R81 81
3 3 2 1 R82 82
2 4 3 5 R83 83
3 3 1 2 R84 84
3 3 2 1 R85 85
1 2 2 2 R86 86
5 5 4 2 R87 87
5 4 5 4 R88 88
4 2 4 4 R89 89
4 5 5 4 R90 90
2 1 2 3 R91 91
4 5 1 5 R92 92
5 5 5 3 R93 93
4 4 1 4 R94 94
2 3 5 1 R95 95
5 1 2 2 R96 96
2 4 2 5 R97 97
3 2 1 3 R98 98
4 2 2 2 R99 99
3 4 4 3 R100 100
4 4 3 5 R101 101
3 4 2 4 R102 102
3 5 3 5 R103 103
1 1 3 2 R104 104
3 1 5 1 R105 105
3 1 1 5 R106 106
3 3 4 4 R107 107
1 4 3 2 R108 108
2 2 1 4 R109 109
5 3 1 5 R110 110
2 3 3 5 R111 111
2 1 4 4 R112 112
2 1 4 4 R113 113
1 5 4 4 R114 114
5 1 4 3 R115 115
2 1 5 2 R116 116
5 2 5 5 R117 117
5 2 4 2 R118 118
3 1 5 1 R119 119
1 4 2 3 R120 120
2 2 5 1 R121 121
3 3 4 5 R122 122
2 2 5 4 R123 123
5 4 1 4 R124 124
2 2 4 2 R125 125
2 4 1 3 R126 126
5 5 2 3 R127 127
4 4 2 4 R128 128
2 3 5 5 R129 129
5 4 3 3 R130 130
4 2 3 4 R131 131
2 3 1 3 R132 132
4 4 3 5 R133 133
2 1 5 4 R134 134
5 1 3 2 R135 135
4 1 1 3 R136 136
4 1 1 2 R137 137
4 5 3 4 R138 138
5 1 1 3 R139 139
2 5 1 1 R140 140
5 4 2 1 R141 141
2 2 2 1 R142 142
2 5 3 2 R143 143
4 3 3 3 R144 144
3 4 3 5 R145 145
5 1 3 4 R146 146
1 4 1 1 R147 147
1 4 2 5 R148 148
3 2 4 2 R149 149
4 1 2 5 R150 150
1 4 4 2 R151 151
5 2 4 2 R152 152
4 1 4 2 R153 153
5 3 3 1 R154 154
3 2 2 5 R155 155
3 3 2 2 R156 156
4 4 3 3 R157 157
1 3 4 1 R158 158
2 5 2 2 R159 159
3 3 1 3 R160 160
3 5 4 1 R161 161
1 1 5 2 R162 162
2 3 2 1 R163 163
2 5 1 4 R164 164
3 2 3 3 R165 165
1 1 2 2 R166 166
3 4 4 1 R167 167
3 4 4 1 R168 168
3 5 2 2 R169 169
2 3 3 5 R170 170
5 2 5 1 R171 171
4 2 5 3 R172 172
4 5 5 2 R173 173
4 3 3 4 R174 174
4 1 1 3 R175 175
5 1 5 3 R176 176
1 3 5 3 R177 177
5 1 2 4 R178 178
5 2 1 5 R179 179
2 1 4 4 R180 180
5 4 1 1 R181 181
3 2 1 5 R182 182
2 2 4 5 R183 183
5 4 1 1 R184 184
4 3 3 5 R185 185
5 4 3 5 R186 186
3 1 1 5 R187 187
2 1 1 2 R188 188
3 3 4 1 R189 189
3 2 4 5 R190 190
2 3 1 4 R191 191
5 2 1 4 R192 192
3 2 2 3 R193 193
4 2 2 4 R194 194
3 5 2 1 R195 195
4 1 2 4 R196 196
1 3 2 1 R197 197
5 4 4 1 R198 198
1 4 4 4 R199 199
4 2 2 1 R200 200
\.
--
-- Data for Name: s; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.s (b1, b2, b3, b4, ann, i) FROM stdin;
4 2 2 5 S1 1
3 3 4 1 S2 2
5 5 5 3 S3 3
5 3 5 2 S4 4
3 4 1 4 S5 5
5 5 4 5 S6 6
3 3 2 3 S7 7
2 3 5 5 S8 8
3 1 3 4 S9 9
1 5 4 1 S10 10
3 5 1 4 S11 11
2 1 5 5 S12 12
4 1 1 5 S13 13
3 5 3 2 S14 14
3 1 4 2 S15 15
1 4 4 4 S16 16
1 2 4 3 S17 17
1 3 5 4 S18 18
1 3 3 3 S19 19
3 1 4 2 S20 20
5 2 2 5 S21 21
4 1 4 2 S22 22
4 5 2 2 S23 23
4 4 4 2 S24 24
1 2 2 3 S25 25
4 4 1 4 S26 26
2 4 4 1 S27 27
1 2 4 4 S28 28
4 3 3 4 S29 29
3 1 5 5 S30 30
3 5 5 1 S31 31
3 1 5 1 S32 32
3 3 1 2 S33 33
4 3 3 3 S34 34
5 2 4 3 S35 35
5 3 2 4 S36 36
4 3 4 1 S37 37
1 4 4 5 S38 38
2 4 1 1 S39 39
4 3 2 4 S40 40
3 4 5 1 S41 41
3 2 3 4 S42 42
5 3 4 4 S43 43
4 3 4 5 S44 44
5 5 1 3 S45 45
3 3 5 4 S46 46
5 1 2 5 S47 47
3 1 4 4 S48 48
1 3 5 4 S49 49
4 5 2 2 S50 50
3 5 4 2 S51 51
4 5 2 2 S52 52
3 3 2 3 S53 53
5 4 2 3 S54 54
3 4 3 5 S55 55
1 4 3 4 S56 56
3 3 4 1 S57 57
3 3 3 3 S58 58
4 1 5 3 S59 59
1 5 5 3 S60 60
2 3 4 1 S61 61
2 2 5 3 S62 62
1 1 5 2 S63 63
4 1 5 5 S64 64
3 5 5 5 S65 65
3 5 4 4 S66 66
1 4 5 1 S67 67
1 3 1 5 S68 68
4 3 1 3 S69 69
4 2 3 2 S70 70
4 3 3 2 S71 71
2 4 3 4 S72 72
5 3 2 3 S73 73
5 5 2 2 S74 74
2 4 5 5 S75 75
1 4 4 2 S76 76
2 2 4 4 S77 77
2 2 2 2 S78 78
2 1 3 3 S79 79
1 2 5 1 S80 80
3 4 3 5 S81 81
2 2 1 3 S82 82
5 4 5 1 S83 83
4 2 1 2 S84 84
2 1 2 2 S85 85
3 1 4 4 S86 86
5 5 5 3 S87 87
4 2 1 5 S88 88
5 1 2 2 S89 89
3 1 3 5 S90 90
4 4 5 5 S91 91
1 5 3 3 S92 92
3 2 1 5 S93 93
4 3 3 4 S94 94
5 3 5 2 S95 95
4 2 3 2 S96 96
1 1 3 4 S97 97
2 1 1 3 S98 98
3 3 4 4 S99 99
2 1 5 2 S100 100
1 2 3 1 S101 101
1 2 1 4 S102 102
1 2 1 3 S103 103
4 4 2 3 S104 104
4 2 2 4 S105 105
2 4 2 5 S106 106
3 2 1 2 S107 107
3 3 1 3 S108 108
5 4 5 3 S109 109
3 2 1 3 S110 110
3 3 1 5 S111 111
3 3 1 2 S112 112
2 3 1 3 S113 113
2 3 4 2 S114 114
4 4 3 2 S115 115
4 4 3 4 S116 116
3 3 3 3 S117 117
3 2 3 4 S118 118
5 1 2 2 S119 119
3 3 3 2 S120 120
3 5 5 4 S121 121
2 3 3 4 S122 122
1 5 2 4 S123 123
3 3 3 2 S124 124
2 2 1 1 S125 125
2 5 2 2 S126 126
5 4 4 1 S127 127
5 3 2 1 S128 128
1 5 1 2 S129 129
5 1 4 2 S130 130
3 1 2 5 S131 131
2 1 5 5 S132 132
1 5 5 5 S133 133
5 2 5 4 S134 134
4 4 2 2 S135 135
5 2 4 5 S136 136
2 1 3 5 S137 137
5 1 4 1 S138 138
4 4 3 2 S139 139
3 4 1 5 S140 140
5 4 3 2 S141 141
3 4 1 4 S142 142
5 1 2 3 S143 143
5 4 1 3 S144 144
4 1 3 5 S145 145
1 1 4 4 S146 146
4 3 2 4 S147 147
4 5 2 3 S148 148
2 3 1 1 S149 149
4 4 1 2 S150 150
3 5 1 2 S151 151
3 2 4 1 S152 152
5 2 4 3 S153 153
1 3 2 5 S154 154
2 5 2 4 S155 155
5 3 1 5 S156 156
2 2 1 2 S157 157
1 3 1 3 S158 158
4 1 3 5 S159 159
5 1 2 1 S160 160
1 1 3 1 S161 161
4 2 1 3 S162 162
3 5 3 4 S163 163
4 1 1 3 S164 164
1 4 3 4 S165 165
1 3 1 5 S166 166
3 3 5 2 S167 167
5 2 2 5 S168 168
4 2 1 3 S169 169
3 5 5 3 S170 170
2 3 2 4 S171 171
5 4 5 5 S172 172
4 3 4 5 S173 173
4 2 1 5 S174 174
1 4 5 1 S175 175
2 1 5 4 S176 176
2 3 1 5 S177 177
4 3 1 2 S178 178
5 1 4 1 S179 179
3 1 1 2 S180 180
4 2 3 2 S181 181
2 2 1 2 S182 182
2 3 1 2 S183 183
2 2 3 2 S184 184
3 3 4 4 S185 185
4 4 2 2 S186 186
4 5 3 3 S187 187
2 4 2 2 S188 188
2 2 1 3 S189 189
4 1 2 3 S190 190
3 2 3 2 S191 191
5 1 3 5 S192 192
2 2 1 5 S193 193
2 2 2 5 S194 194
1 4 4 2 S195 195
4 3 2 1 S196 196
2 2 1 5 S197 197
4 3 3 2 S198 198
5 3 3 1 S199 199
4 4 2 5 S200 200
\.
--
-- Name: r_i_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.r_i_seq', 200, true);
--
-- Name: s_i_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.s_i_seq', 200, true);
--
-- Name: r r_ann_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.r
ADD CONSTRAINT r_ann_key UNIQUE (ann);
--
-- Name: r r_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.r
ADD CONSTRAINT r_pkey PRIMARY KEY (i);
--
-- Name: s s_ann_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.s
ADD CONSTRAINT s_ann_key UNIQUE (ann);
--
-- Name: s s_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.s
ADD CONSTRAINT s_pkey PRIMARY KEY (i);
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+161
View File
@@ -0,0 +1,161 @@
-- Downloaded from: https://github.com/kirooha/adtech-simple/blob/a1cf7c0607bd2aea3e6aa2d042c9fe2b4e28e797/db/structure.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 13.8
-- Dumped by pg_dump version 16.0
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;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--
-- *not* creating schema, since initdb creates it
--
-- Name: set_updated_at_column(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.set_updated_at_column() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = now() at time zone 'utc';
RETURN NEW;
END;
$$;
SET default_table_access_method = heap;
--
-- Name: campaigns; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.campaigns (
id uuid DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
description text NOT NULL,
adserver_id uuid,
created_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL,
updated_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL
);
--
-- Name: goose_db_version; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.goose_db_version (
id integer NOT NULL,
version_id bigint NOT NULL,
is_applied boolean NOT NULL,
tstamp timestamp without time zone DEFAULT now()
);
--
-- Name: goose_db_version_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.goose_db_version_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: goose_db_version_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.goose_db_version_id_seq OWNED BY public.goose_db_version.id;
--
-- Name: gue_jobs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.gue_jobs (
job_id text NOT NULL,
priority smallint NOT NULL,
run_at timestamp with time zone NOT NULL,
job_type text NOT NULL,
args bytea NOT NULL,
error_count integer DEFAULT 0 NOT NULL,
last_error text,
queue text NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
);
--
-- Name: goose_db_version id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.goose_db_version ALTER COLUMN id SET DEFAULT nextval('public.goose_db_version_id_seq'::regclass);
--
-- Name: goose_db_version goose_db_version_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.goose_db_version
ADD CONSTRAINT goose_db_version_pkey PRIMARY KEY (id);
--
-- Name: gue_jobs gue_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.gue_jobs
ADD CONSTRAINT gue_jobs_pkey PRIMARY KEY (job_id);
--
-- Name: campaigns__adserver_id__uidx; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX campaigns__adserver_id__uidx ON public.campaigns USING btree (adserver_id);
--
-- Name: campaigns__name__uidx; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX campaigns__name__uidx ON public.campaigns USING btree (name);
--
-- Name: idx_gue_jobs_selector; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_gue_jobs_selector ON public.gue_jobs USING btree (queue, run_at, priority);
--
-- Name: campaigns update_campaign_updated_at; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER update_campaign_updated_at BEFORE UPDATE ON public.campaigns FOR EACH ROW EXECUTE FUNCTION public.set_updated_at_column();
--
-- PostgreSQL database dump complete
--
+752
View File
@@ -0,0 +1,752 @@
-- Downloaded from: https://github.com/kjanus03/tsn/blob/4b71c1446d26e4a0dc10707297d52554ab66dfc4/tsn_db_architecture.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 17.5
-- Dumped by pg_dump version 17.5
-- Started on 2025-06-03 16:37:21
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;
--
-- TOC entry 886 (class 1247 OID 16516)
-- Name: genderenum; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.genderenum AS ENUM (
'MALE',
'FEMALE',
'OTHER',
'PREFER_NOT_TO_SAY'
);
ALTER TYPE public.genderenum OWNER TO postgres;
--
-- TOC entry 868 (class 1247 OID 16414)
-- Name: visibilityenum; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.visibilityenum AS ENUM (
'PUBLIC',
'FRIENDS',
'PRIVATE'
);
ALTER TYPE public.visibilityenum OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 217 (class 1259 OID 16394)
-- Name: alembic_version; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.alembic_version (
version_num character varying(32) NOT NULL
);
ALTER TABLE public.alembic_version OWNER TO postgres;
--
-- TOC entry 229 (class 1259 OID 16546)
-- Name: comment; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.comment (
id integer NOT NULL,
user_id integer NOT NULL,
post_id integer,
content text NOT NULL,
"timestamp" timestamp without time zone NOT NULL,
share_id integer
);
ALTER TABLE public.comment OWNER TO postgres;
--
-- TOC entry 228 (class 1259 OID 16545)
-- Name: comment_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.comment_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.comment_id_seq OWNER TO postgres;
--
-- TOC entry 4998 (class 0 OID 0)
-- Dependencies: 228
-- Name: comment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.comment_id_seq OWNED BY public.comment.id;
--
-- TOC entry 222 (class 1259 OID 16435)
-- Name: friendships; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.friendships (
user_id integer NOT NULL,
friend_id integer NOT NULL
);
ALTER TABLE public.friendships OWNER TO postgres;
--
-- TOC entry 224 (class 1259 OID 16451)
-- Name: like; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."like" (
id integer NOT NULL,
user_id integer NOT NULL,
post_id integer,
comment_id integer,
share_id integer,
"timestamp" timestamp without time zone
);
ALTER TABLE public."like" OWNER TO postgres;
--
-- TOC entry 223 (class 1259 OID 16450)
-- Name: like_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.like_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.like_id_seq OWNER TO postgres;
--
-- TOC entry 4999 (class 0 OID 0)
-- Dependencies: 223
-- Name: like_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.like_id_seq OWNED BY public."like".id;
--
-- TOC entry 233 (class 1259 OID 16611)
-- Name: message; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.message (
id integer NOT NULL,
sender_id integer NOT NULL,
recipient_id integer NOT NULL,
content text NOT NULL,
"timestamp" timestamp without time zone NOT NULL,
is_read boolean NOT NULL
);
ALTER TABLE public.message OWNER TO postgres;
--
-- TOC entry 232 (class 1259 OID 16610)
-- Name: message_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.message_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.message_id_seq OWNER TO postgres;
--
-- TOC entry 5000 (class 0 OID 0)
-- Dependencies: 232
-- Name: message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.message_id_seq OWNED BY public.message.id;
--
-- TOC entry 221 (class 1259 OID 16422)
-- Name: post; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.post (
id integer NOT NULL,
user_id integer NOT NULL,
content text NOT NULL,
visibility public.visibilityenum NOT NULL,
"timestamp" timestamp without time zone NOT NULL,
media character varying(255)
);
ALTER TABLE public.post OWNER TO postgres;
--
-- TOC entry 220 (class 1259 OID 16421)
-- Name: post_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.post_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.post_id_seq OWNER TO postgres;
--
-- TOC entry 5001 (class 0 OID 0)
-- Dependencies: 220
-- Name: post_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.post_id_seq OWNED BY public.post.id;
--
-- TOC entry 226 (class 1259 OID 16470)
-- Name: role; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.role (
id integer NOT NULL,
name character varying(80),
description character varying(255)
);
ALTER TABLE public.role OWNER TO postgres;
--
-- TOC entry 225 (class 1259 OID 16469)
-- Name: role_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.role_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.role_id_seq OWNER TO postgres;
--
-- TOC entry 5002 (class 0 OID 0)
-- Dependencies: 225
-- Name: role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.role_id_seq OWNED BY public.role.id;
--
-- TOC entry 227 (class 1259 OID 16478)
-- Name: roles_users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.roles_users (
user_id integer,
role_id integer
);
ALTER TABLE public.roles_users OWNER TO postgres;
--
-- TOC entry 231 (class 1259 OID 16565)
-- Name: share; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.share (
id integer NOT NULL,
user_id integer NOT NULL,
post_id integer NOT NULL,
content text,
"timestamp" timestamp without time zone NOT NULL
);
ALTER TABLE public.share OWNER TO postgres;
--
-- TOC entry 230 (class 1259 OID 16564)
-- Name: share_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.share_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.share_id_seq OWNER TO postgres;
--
-- TOC entry 5003 (class 0 OID 0)
-- Dependencies: 230
-- Name: share_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.share_id_seq OWNED BY public.share.id;
--
-- TOC entry 219 (class 1259 OID 16400)
-- Name: user; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."user" (
id integer NOT NULL,
is_active boolean DEFAULT true NOT NULL,
username character varying(64) NOT NULL,
email character varying(255) NOT NULL,
password character varying(255) NOT NULL,
phone character varying(64) NOT NULL,
date_birth date NOT NULL,
gender public.genderenum NOT NULL,
fs_uniquifier character varying(255) NOT NULL,
confirmed_at timestamp without time zone,
profile_pic character varying(255) NOT NULL,
first_name character varying(64) NOT NULL,
last_name character varying(64) NOT NULL,
biography text,
location character varying(100),
date_joined date NOT NULL
);
ALTER TABLE public."user" OWNER TO postgres;
--
-- TOC entry 218 (class 1259 OID 16399)
-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.user_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.user_id_seq OWNER TO postgres;
--
-- TOC entry 5004 (class 0 OID 0)
-- Dependencies: 218
-- Name: user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.user_id_seq OWNED BY public."user".id;
--
-- TOC entry 4795 (class 2604 OID 16549)
-- Name: comment id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comment ALTER COLUMN id SET DEFAULT nextval('public.comment_id_seq'::regclass);
--
-- TOC entry 4793 (class 2604 OID 16454)
-- Name: like id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like" ALTER COLUMN id SET DEFAULT nextval('public.like_id_seq'::regclass);
--
-- TOC entry 4797 (class 2604 OID 16614)
-- Name: message id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.message ALTER COLUMN id SET DEFAULT nextval('public.message_id_seq'::regclass);
--
-- TOC entry 4792 (class 2604 OID 16425)
-- Name: post id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.post ALTER COLUMN id SET DEFAULT nextval('public.post_id_seq'::regclass);
--
-- TOC entry 4794 (class 2604 OID 16473)
-- Name: role id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.role ALTER COLUMN id SET DEFAULT nextval('public.role_id_seq'::regclass);
--
-- TOC entry 4796 (class 2604 OID 16568)
-- Name: share id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.share ALTER COLUMN id SET DEFAULT nextval('public.share_id_seq'::regclass);
--
-- TOC entry 4790 (class 2604 OID 16403)
-- Name: user id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."user" ALTER COLUMN id SET DEFAULT nextval('public.user_id_seq'::regclass);
--
-- TOC entry 4799 (class 2606 OID 16398)
-- Name: alembic_version alembic_version_pkc; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.alembic_version
ADD CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num);
--
-- TOC entry 4827 (class 2606 OID 16553)
-- Name: comment comment_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comment
ADD CONSTRAINT comment_pkey PRIMARY KEY (id);
--
-- TOC entry 4813 (class 2606 OID 16439)
-- Name: friendships friendships_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.friendships
ADD CONSTRAINT friendships_pkey PRIMARY KEY (user_id, friend_id);
--
-- TOC entry 4815 (class 2606 OID 16456)
-- Name: like like_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like"
ADD CONSTRAINT like_pkey PRIMARY KEY (id);
--
-- TOC entry 4831 (class 2606 OID 16618)
-- Name: message message_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.message
ADD CONSTRAINT message_pkey PRIMARY KEY (id);
--
-- TOC entry 4811 (class 2606 OID 16429)
-- Name: post post_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.post
ADD CONSTRAINT post_pkey PRIMARY KEY (id);
--
-- TOC entry 4823 (class 2606 OID 16477)
-- Name: role role_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.role
ADD CONSTRAINT role_name_key UNIQUE (name);
--
-- TOC entry 4825 (class 2606 OID 16475)
-- Name: role role_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.role
ADD CONSTRAINT role_pkey PRIMARY KEY (id);
--
-- TOC entry 4829 (class 2606 OID 16572)
-- Name: share share_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.share
ADD CONSTRAINT share_pkey PRIMARY KEY (id);
--
-- TOC entry 4817 (class 2606 OID 16584)
-- Name: like uq_user_comment_like; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like"
ADD CONSTRAINT uq_user_comment_like UNIQUE (user_id, comment_id);
--
-- TOC entry 4819 (class 2606 OID 16586)
-- Name: like uq_user_post_like; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like"
ADD CONSTRAINT uq_user_post_like UNIQUE (user_id, post_id);
--
-- TOC entry 4821 (class 2606 OID 16588)
-- Name: like uq_user_share_like; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like"
ADD CONSTRAINT uq_user_share_like UNIQUE (user_id, share_id);
--
-- TOC entry 4801 (class 2606 OID 16410)
-- Name: user user_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."user"
ADD CONSTRAINT user_email_key UNIQUE (email);
--
-- TOC entry 4803 (class 2606 OID 16492)
-- Name: user user_fs_uniquifier_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."user"
ADD CONSTRAINT user_fs_uniquifier_key UNIQUE (fs_uniquifier);
--
-- TOC entry 4805 (class 2606 OID 16494)
-- Name: user user_phone_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."user"
ADD CONSTRAINT user_phone_key UNIQUE (phone);
--
-- TOC entry 4807 (class 2606 OID 16408)
-- Name: user user_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."user"
ADD CONSTRAINT user_pkey PRIMARY KEY (id);
--
-- TOC entry 4809 (class 2606 OID 16412)
-- Name: user user_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."user"
ADD CONSTRAINT user_username_key UNIQUE (username);
--
-- TOC entry 4841 (class 2606 OID 16554)
-- Name: comment comment_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comment
ADD CONSTRAINT comment_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.post(id) ON DELETE CASCADE;
--
-- TOC entry 4842 (class 2606 OID 16629)
-- Name: comment comment_share_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comment
ADD CONSTRAINT comment_share_id_fkey FOREIGN KEY (share_id) REFERENCES public.share(id) ON DELETE CASCADE;
--
-- TOC entry 4843 (class 2606 OID 16559)
-- Name: comment comment_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comment
ADD CONSTRAINT comment_user_id_fkey FOREIGN KEY (user_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- TOC entry 4833 (class 2606 OID 16440)
-- Name: friendships friendships_friend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.friendships
ADD CONSTRAINT friendships_friend_id_fkey FOREIGN KEY (friend_id) REFERENCES public."user"(id);
--
-- TOC entry 4834 (class 2606 OID 16445)
-- Name: friendships friendships_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.friendships
ADD CONSTRAINT friendships_user_id_fkey FOREIGN KEY (user_id) REFERENCES public."user"(id);
--
-- TOC entry 4835 (class 2606 OID 16589)
-- Name: like like_comment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like"
ADD CONSTRAINT like_comment_id_fkey FOREIGN KEY (comment_id) REFERENCES public.comment(id) ON DELETE CASCADE;
--
-- TOC entry 4836 (class 2606 OID 16599)
-- Name: like like_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like"
ADD CONSTRAINT like_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.post(id) ON DELETE CASCADE;
--
-- TOC entry 4837 (class 2606 OID 16594)
-- Name: like like_share_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like"
ADD CONSTRAINT like_share_id_fkey FOREIGN KEY (share_id) REFERENCES public.share(id) ON DELETE CASCADE;
--
-- TOC entry 4838 (class 2606 OID 16604)
-- Name: like like_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."like"
ADD CONSTRAINT like_user_id_fkey FOREIGN KEY (user_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- TOC entry 4846 (class 2606 OID 16619)
-- Name: message message_recipient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.message
ADD CONSTRAINT message_recipient_id_fkey FOREIGN KEY (recipient_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- TOC entry 4847 (class 2606 OID 16624)
-- Name: message message_sender_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.message
ADD CONSTRAINT message_sender_id_fkey FOREIGN KEY (sender_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- TOC entry 4832 (class 2606 OID 16430)
-- Name: post post_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.post
ADD CONSTRAINT post_user_id_fkey FOREIGN KEY (user_id) REFERENCES public."user"(id);
--
-- TOC entry 4839 (class 2606 OID 16481)
-- Name: roles_users roles_users_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.roles_users
ADD CONSTRAINT roles_users_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.role(id);
--
-- TOC entry 4840 (class 2606 OID 16486)
-- Name: roles_users roles_users_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.roles_users
ADD CONSTRAINT roles_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES public."user"(id);
--
-- TOC entry 4844 (class 2606 OID 16573)
-- Name: share share_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.share
ADD CONSTRAINT share_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.post(id) ON DELETE CASCADE;
--
-- TOC entry 4845 (class 2606 OID 16578)
-- Name: share share_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.share
ADD CONSTRAINT share_user_id_fkey FOREIGN KEY (user_id) REFERENCES public."user"(id) ON DELETE CASCADE;
-- Completed on 2025-06-03 16:37:22
--
-- PostgreSQL database dump complete
--
+181
View File
@@ -0,0 +1,181 @@
-- Downloaded from: https://github.com/kraftn/queue-server/blob/f88a3bc49507714647e953b70818dcd0cb1c80df/database/backup.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.4
-- Dumped by pg_dump version 11.4
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;
--
-- Name: get_top(character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.get_top(find_type character varying) RETURNS TABLE(id bigint, kind bigint, status character varying, input text, output text)
LANGUAGE sql
AS $$select * from main_queue
where id = (select min(id) from main_queue
where kind in (select id from task_types
where kind = find_type) and status = 'В очереди')$$;
ALTER FUNCTION public.get_top(find_type character varying) OWNER TO postgres;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: main_queue; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.main_queue (
id bigint NOT NULL,
kind bigint NOT NULL,
status character varying(100) NOT NULL,
input text NOT NULL,
output text
);
ALTER TABLE public.main_queue OWNER TO postgres;
--
-- Name: main_queue_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.main_queue_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.main_queue_id_seq OWNER TO postgres;
--
-- Name: main_queue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.main_queue_id_seq OWNED BY public.main_queue.id;
--
-- Name: task_types; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.task_types (
id bigint NOT NULL,
kind character varying(100) NOT NULL
);
ALTER TABLE public.task_types OWNER TO postgres;
--
-- Name: task_types_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.task_types_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.task_types_id_seq OWNER TO postgres;
--
-- Name: task_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.task_types_id_seq OWNED BY public.task_types.id;
--
-- Name: main_queue id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.main_queue ALTER COLUMN id SET DEFAULT nextval('public.main_queue_id_seq'::regclass);
--
-- Name: task_types id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.task_types ALTER COLUMN id SET DEFAULT nextval('public.task_types_id_seq'::regclass);
--
-- Data for Name: main_queue; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.main_queue (id, kind, status, input, output) FROM stdin;
\.
--
-- Data for Name: task_types; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.task_types (id, kind) FROM stdin;
11 E-mail
7 Квадратное уравнение
10 Перевод
\.
--
-- Name: main_queue_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.main_queue_id_seq', 14693, true);
--
-- Name: task_types_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.task_types_id_seq', 14, true);
--
-- Name: main_queue main_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.main_queue
ADD CONSTRAINT main_queue_pkey PRIMARY KEY (id);
--
-- Name: task_types task_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.task_types
ADD CONSTRAINT task_types_pkey PRIMARY KEY (id);
--
-- Name: main_queue main_queue_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.main_queue
ADD CONSTRAINT main_queue_type_fkey FOREIGN KEY (kind) REFERENCES public.task_types(id);
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,123 @@
-- Downloaded from: https://github.com/linvivian7/fe-react-16-demo/blob/6ababddceccfc0320ae1739fc0152335740bbadc/vocab.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.2
-- Dumped by pg_dump version 9.6.2
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: vocabulary; Type: TABLE; Schema: public; Owner: Admin
--
CREATE TABLE vocabulary (
id integer NOT NULL,
jp_word character varying(50) NOT NULL,
en_word character varying(50) NOT NULL
);
ALTER TABLE vocabulary OWNER TO "Admin";
--
-- Name: vocabulary_id_seq; Type: SEQUENCE; Schema: public; Owner: Admin
--
CREATE SEQUENCE vocabulary_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE vocabulary_id_seq OWNER TO "Admin";
--
-- Name: vocabulary_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: Admin
--
ALTER SEQUENCE vocabulary_id_seq OWNED BY vocabulary.id;
--
-- Name: vocabulary id; Type: DEFAULT; Schema: public; Owner: Admin
--
ALTER TABLE ONLY vocabulary ALTER COLUMN id SET DEFAULT nextval('vocabulary_id_seq'::regclass);
--
-- Data for Name: vocabulary; Type: TABLE DATA; Schema: public; Owner: Admin
--
COPY vocabulary (id, jp_word, en_word) FROM stdin;
1 itemization
2 things to be done
3 resistance
4 infect
5 to excel
6 confess
7 showy, brilliant
8 scorn, disdain
9 to build
10 coliving
11 independent
12 沿 along
13 pollen
14 once
15 spasm
16 organs
18 liquid
19 predecessor
\.
--
-- Name: vocabulary_id_seq; Type: SEQUENCE SET; Schema: public; Owner: Admin
--
SELECT pg_catalog.setval('vocabulary_id_seq', 19, true);
--
-- Name: vocabulary vocabulary_pkey; Type: CONSTRAINT; Schema: public; Owner: Admin
--
ALTER TABLE ONLY vocabulary
ADD CONSTRAINT vocabulary_pkey PRIMARY KEY (id);
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,504 @@
-- Downloaded from: https://github.com/littlebunch/graphql-rs/blob/f5169da015094669fd8058c11706bbe68b56c18b/database/pg/up.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 13.0
-- Dumped by pg_dump version 13.0
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;
--
-- Name: diesel_manage_updated_at(regclass); Type: FUNCTION; Schema: public; Owner: gmoore
--
CREATE FUNCTION public.diesel_manage_updated_at(_tbl regclass) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s
FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl);
END;
$$;
ALTER FUNCTION public.diesel_manage_updated_at(_tbl regclass) OWNER TO gmoore;
--
-- Name: diesel_set_updated_at(); Type: FUNCTION; Schema: public; Owner: gmoore
--
CREATE FUNCTION public.diesel_set_updated_at() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF (
NEW IS DISTINCT FROM OLD AND
NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at
) THEN
NEW.updated_at := current_timestamp;
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.diesel_set_updated_at() OWNER TO gmoore;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: __diesel_schema_migrations; Type: TABLE; Schema: public; Owner: gmoore
--
CREATE TABLE public.__diesel_schema_migrations (
version character varying(50) NOT NULL,
run_on timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
ALTER TABLE public.__diesel_schema_migrations OWNER TO gmoore;
--
-- Name: derivations; Type: TABLE; Schema: public; Owner: gmoore
--
CREATE TABLE public.derivations (
id integer NOT NULL,
code character varying(255) NOT NULL,
description text NOT NULL
);
ALTER TABLE public.derivations OWNER TO gmoore;
--
-- Name: derivations_id_seq; Type: SEQUENCE; Schema: public; Owner: gmoore
--
CREATE SEQUENCE public.derivations_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.derivations_id_seq OWNER TO gmoore;
--
-- Name: derivations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gmoore
--
ALTER SEQUENCE public.derivations_id_seq OWNED BY public.derivations.id;
--
-- Name: food_groups; Type: TABLE; Schema: public; Owner: gmoore
--
CREATE TABLE public.food_groups (
id integer NOT NULL,
description character varying(255) DEFAULT ''::character varying NOT NULL
);
ALTER TABLE public.food_groups OWNER TO gmoore;
--
-- Name: foods; Type: TABLE; Schema: public; Owner: gmoore
--
CREATE TABLE public.foods (
id integer NOT NULL,
publication_date timestamp with time zone NOT NULL,
modified_date timestamp with time zone NOT NULL,
available_date timestamp with time zone NOT NULL,
upc character varying(24) NOT NULL,
fdc_id character varying(24) NOT NULL,
description character varying(255) NOT NULL,
food_group_id integer DEFAULT 0 NOT NULL,
manufacturer_id integer DEFAULT 0 NOT NULL,
datasource character varying(8) NOT NULL,
serving_size double precision,
serving_unit character varying(24) DEFAULT NULL::character varying,
serving_description character varying(256) DEFAULT NULL::character varying,
country character varying(24) DEFAULT NULL::character varying,
ingredients text,
kw_tsvector tsvector GENERATED ALWAYS AS (to_tsvector('english'::regconfig, (((COALESCE(description, ''::character varying))::text || ' '::text) || COALESCE(ingredients, ''::text)))) STORED
);
ALTER TABLE public.foods OWNER TO gmoore;
--
-- Name: manufacturers; Type: TABLE; Schema: public; Owner: gmoore
--
CREATE TABLE public.manufacturers (
id integer NOT NULL,
name character varying(255) DEFAULT ''::character varying NOT NULL
);
ALTER TABLE public.manufacturers OWNER TO gmoore;
--
-- Name: food_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: gmoore
--
CREATE SEQUENCE public.food_groups_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.food_groups_id_seq OWNER TO gmoore;
--
-- Name: food_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gmoore
--
ALTER SEQUENCE public.food_groups_id_seq OWNED BY public.food_groups.id;
--
-- Name: foods_id_seq; Type: SEQUENCE; Schema: public; Owner: gmoore
--
CREATE SEQUENCE public.foods_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.foods_id_seq OWNER TO gmoore;
--
-- Name: foods_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gmoore
--
ALTER SEQUENCE public.foods_id_seq OWNED BY public.foods.id;
--
-- Name: manufacturers_id_seq; Type: SEQUENCE; Schema: public; Owner: gmoore
--
CREATE SEQUENCE public.manufacturers_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.manufacturers_id_seq OWNER TO gmoore;
--
-- Name: manufacturers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gmoore
--
ALTER SEQUENCE public.manufacturers_id_seq OWNED BY public.manufacturers.id;
--
-- Name: nutrient_data; Type: TABLE; Schema: public; Owner: gmoore
--
CREATE TABLE public.nutrient_data (
id integer NOT NULL,
value double precision DEFAULT '0'::double precision NOT NULL,
standard_error double precision,
minimum double precision,
maximum double precision,
median double precision,
derivation_id integer DEFAULT 0 NOT NULL,
nutrient_id integer DEFAULT 0 NOT NULL,
food_id integer DEFAULT 0 NOT NULL
);
ALTER TABLE public.nutrient_data OWNER TO gmoore;
--
-- Name: nutrient_data_id_seq; Type: SEQUENCE; Schema: public; Owner: gmoore
--
CREATE SEQUENCE public.nutrient_data_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.nutrient_data_id_seq OWNER TO gmoore;
--
-- Name: nutrient_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: gmoore
--
ALTER SEQUENCE public.nutrient_data_id_seq OWNED BY public.nutrient_data.id;
--
-- Name: nutrients; Type: TABLE; Schema: public; Owner: gmoore
--
CREATE TABLE public.nutrients (
id integer NOT NULL,
nutrientno character varying(12) NOT NULL,
description character varying(255) NOT NULL,
unit character varying(24) NOT NULL
);
ALTER TABLE public.nutrients OWNER TO gmoore;
--
-- Name: derivations id; Type: DEFAULT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.derivations ALTER COLUMN id SET DEFAULT nextval('public.derivations_id_seq'::regclass);
--
-- Name: food_groups id; Type: DEFAULT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.food_groups ALTER COLUMN id SET DEFAULT nextval('public.food_groups_id_seq'::regclass);
--
-- Name: foods id; Type: DEFAULT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.foods ALTER COLUMN id SET DEFAULT nextval('public.foods_id_seq'::regclass);
--
-- Name: manufacturers id; Type: DEFAULT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.manufacturers ALTER COLUMN id SET DEFAULT nextval('public.manufacturers_id_seq'::regclass);
--
-- Name: nutrient_data id; Type: DEFAULT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.nutrient_data ALTER COLUMN id SET DEFAULT nextval('public.nutrient_data_id_seq'::regclass);
--
-- Name: __diesel_schema_migrations __diesel_schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.__diesel_schema_migrations
ADD CONSTRAINT __diesel_schema_migrations_pkey PRIMARY KEY (version);
--
-- Name: derivations derivations_pkey; Type: CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.derivations
ADD CONSTRAINT derivations_pkey PRIMARY KEY (id);
--
-- Name: food_groups food_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.food_groups
ADD CONSTRAINT food_groups_pkey PRIMARY KEY (id);
--
-- Name: foods foods_pkey; Type: CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.foods
ADD CONSTRAINT foods_pkey PRIMARY KEY (id);
--
-- Name: manufacturers manufacturers_pkey; Type: CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.manufacturers
ADD CONSTRAINT manufacturers_pkey PRIMARY KEY (id);
--
-- Name: nutrient_data nutrient_data_pkey; Type: CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.nutrient_data
ADD CONSTRAINT nutrient_data_pkey PRIMARY KEY (id);
--
-- Name: nutrients nutrients_pkey; Type: CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.nutrients
ADD CONSTRAINT nutrients_pkey PRIMARY KEY (id);
--
-- Name: idx_16458_foods_description_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16458_foods_description_idx ON public.foods USING btree (description);
--
-- Name: idx_16458_foods_fdc_id_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16458_foods_fdc_id_idx ON public.foods USING btree (fdc_id);
--
-- Name: idx_16458_foods_fk; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16458_foods_fk ON public.foods USING btree (manufacturer_id);
--
-- Name: idx_16458_foods_food_group_id_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16458_foods_food_group_id_idx ON public.foods USING btree (food_group_id);
--
-- Name: idx_16458_foods_manufacturer_id_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16458_foods_manufacturer_id_idx ON public.foods USING btree (manufacturer_id);
--
-- Name: idx_16458_foods_upc_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16458_foods_upc_idx ON public.foods USING btree (upc);
--
-- Name: idx_16472_food_groups_description_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16472_food_groups_description_idx ON public.food_groups USING btree (description);
--
-- Name: idx_16479_manufacturers_name_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16479_manufacturers_name_idx ON public.manufacturers USING btree (name);
--
-- Name: idx_16484_nutrientno; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE UNIQUE INDEX idx_16484_nutrientno ON public.nutrients USING btree (nutrientno);
--
-- Name: idx_16489_nutrient_data_fk; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16489_nutrient_data_fk ON public.nutrient_data USING btree (nutrient_id);
--
-- Name: idx_16489_nutrient_data_fk_1; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16489_nutrient_data_fk_1 ON public.nutrient_data USING btree (derivation_id);
--
-- Name: idx_16489_nutrient_data_food_id_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX idx_16489_nutrient_data_food_id_idx ON public.nutrient_data USING btree (food_id);
--
-- Name: kw_tsvector_idx; Type: INDEX; Schema: public; Owner: gmoore
--
CREATE INDEX kw_tsvector_idx ON public.foods USING gin (kw_tsvector);
--
-- Name: foods foods_fk; Type: FK CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.foods
ADD CONSTRAINT foods_fk FOREIGN KEY (manufacturer_id) REFERENCES public.manufacturers(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: foods foods_fk_1; Type: FK CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.foods
ADD CONSTRAINT foods_fk_1 FOREIGN KEY (food_group_id) REFERENCES public.food_groups(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: nutrient_data nutrient_data_fk; Type: FK CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.nutrient_data
ADD CONSTRAINT nutrient_data_fk FOREIGN KEY (nutrient_id) REFERENCES public.nutrients(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: nutrient_data nutrient_data_fk_1; Type: FK CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.nutrient_data
ADD CONSTRAINT nutrient_data_fk_1 FOREIGN KEY (derivation_id) REFERENCES public.derivations(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: nutrient_data nutrient_data_food_fk; Type: FK CONSTRAINT; Schema: public; Owner: gmoore
--
ALTER TABLE ONLY public.nutrient_data
ADD CONSTRAINT nutrient_data_food_fk FOREIGN KEY (food_id) REFERENCES public.foods(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
+442
View File
@@ -0,0 +1,442 @@
-- Downloaded from: https://github.com/mintas123/Buddies-API/blob/9242d73958c75da6f9d4275a13b5f9e5597aeb9b/src/dbinit/old_init.sql
--TODO rethink database schema
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.3
-- Dumped by pg_dump version 12.4
-- Started on 2020-11-16 13:28:14
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;
CREATE FUNCTION public.distance(lat double precision, lng double precision, db_lat double precision,
db_lng double precision) RETURNS double precision
LANGUAGE plpgsql
AS
$$
begin
return
6371 * acos(
cos(radians(lat)) * cos(radians(db_lat))
*
cos(radians(db_lng) - radians(lng))
+
sin(radians(lat))
*
sin(radians(db_lat))
);
end;
$$;
ALTER FUNCTION public.distance(lat double precision, lng double precision, db_lat double precision, db_lng double precision) OWNER TO postgres;
SET
default_tablespace = '';
SET
default_table_access_method = heap;
--
-- TOC entry 202 (class 1259 OID 16402)
-- Name: account; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.account
(
account_id uuid NOT NULL,
email character varying(63),
phone character varying(31),
hashed_password character varying(255),
name character varying(63),
last_name character varying(63),
birthday date,
gender character varying(15),
description character varying(2000),
age_pref character varying(15),
count_pref character varying(15),
gender_pref character varying(15),
location_str character varying(255),
location_lat double precision NOT NULL,
location_lng double precision NOT NULL,
photo_url character varying(255)
);
ALTER TABLE public.account
OWNER TO postgres;
--
-- TOC entry 203 (class 1259 OID 16411)
-- Name: account_nay; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.account_nay
(
account_id uuid NOT NULL,
nay_tags character varying(255)
);
ALTER TABLE public.account_nay
OWNER TO postgres;
--
-- TOC entry 204 (class 1259 OID 16414)
-- Name: account_tags; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.account_tags
(
account_id uuid NOT NULL,
about_tags character varying(255)
);
ALTER TABLE public.account_tags
OWNER TO postgres;
--
-- TOC entry 205 (class 1259 OID 16417)
-- Name: account_yay; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.account_yay
(
account_id uuid NOT NULL,
yay_tags character varying(255)
);
ALTER TABLE public.account_yay
OWNER TO postgres;
--
-- TOC entry 213 (class 1259 OID 24599)
-- Name: chat_message; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.chat_message
(
id uuid NOT NULL,
chat_id character varying(255),
content character varying(500),
recipient_id uuid,
recipient_name character varying(255),
sender_id uuid,
sender_name character varying(255),
status character varying(255),
"timestamp" timestamp without time zone
);
ALTER TABLE public.chat_message
OWNER TO postgres;
--
-- TOC entry 212 (class 1259 OID 24594)
-- Name: chat_room; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.chat_room
(
id uuid NOT NULL,
chat_id character varying(255),
recipient_id uuid,
sender_id uuid
);
ALTER TABLE public.chat_room
OWNER TO postgres;
--
-- TOC entry 206 (class 1259 OID 16423)
-- Name: fav_rental; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.fav_rental
(
account_id uuid NOT NULL,
rental_id uuid NOT NULL
);
ALTER TABLE public.fav_rental
OWNER TO postgres;
--
-- TOC entry 207 (class 1259 OID 16426)
-- Name: feature_tags; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.feature_tags
(
rental_id uuid NOT NULL,
feature_tags character varying(255)
);
ALTER TABLE public.feature_tags
OWNER TO postgres;
--
-- TOC entry 208 (class 1259 OID 16429)
-- Name: friends_table; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.friends_table
(
account_id uuid NOT NULL,
friend_id uuid NOT NULL
);
ALTER TABLE public.friends_table
OWNER TO postgres;
--
-- TOC entry 209 (class 1259 OID 16432)
-- Name: hibernate_sequence; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.hibernate_sequence
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE CACHE 1;
ALTER TABLE public.hibernate_sequence
OWNER TO postgres;
--
-- TOC entry 210 (class 1259 OID 16437)
-- Name: rental; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.rental
(
rental_id uuid NOT NULL,
creator_id uuid,
title character varying(100),
is_negotiable boolean NOT NULL,
description character varying(3000),
build_year integer NOT NULL,
price integer NOT NULL,
deposit integer NOT NULL,
price_m_sq double precision,
rent_date date,
size double precision NOT NULL,
rooms integer NOT NULL,
floor integer NOT NULL,
location_lat double precision NOT NULL,
location_lng double precision NOT NULL,
location_str character varying(255)
);
ALTER TABLE public.rental
OWNER TO postgres;
--
-- TOC entry 211 (class 1259 OID 16443)
-- Name: rental_pic_urls; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.rental_pic_urls
(
rental_id uuid NOT NULL,
photo_urls character varying(255)
);
ALTER TABLE public.rental_pic_urls
OWNER TO postgres;
--
-- TOC entry 3727 (class 2606 OID 16449)
-- Name: account account_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.account
ADD CONSTRAINT account_pkey PRIMARY KEY (account_id);
--
-- TOC entry 3737 (class 2606 OID 24606)
-- Name: chat_message chat_message_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.chat_message
ADD CONSTRAINT chat_message_pkey PRIMARY KEY (id);
--
-- TOC entry 3735 (class 2606 OID 24598)
-- Name: chat_room chat_room_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.chat_room
ADD CONSTRAINT chat_room_pkey PRIMARY KEY (id);
--
-- TOC entry 3729 (class 2606 OID 16453)
-- Name: fav_rental fav_rental_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.fav_rental
ADD CONSTRAINT fav_rental_pkey PRIMARY KEY (account_id, rental_id);
--
-- TOC entry 3731 (class 2606 OID 16455)
-- Name: friends_table friends_table_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.friends_table
ADD CONSTRAINT friends_table_pkey PRIMARY KEY (friend_id, account_id);
--
-- TOC entry 3733 (class 2606 OID 16459)
-- Name: rental rental_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.rental
ADD CONSTRAINT rental_pkey PRIMARY KEY (rental_id);
--
-- TOC entry 3738 (class 2606 OID 16465)
-- Name: account_nay fk395putnww4q5y1ydsuup5kuf1; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.account_nay
ADD CONSTRAINT fk395putnww4q5y1ydsuup5kuf1 FOREIGN KEY (account_id) REFERENCES public.account (account_id);
--
-- TOC entry 3743 (class 2606 OID 16470)
-- Name: feature_tags fk459dt6ppn8jq0m0rbsskup6kb; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.feature_tags
ADD CONSTRAINT fk459dt6ppn8jq0m0rbsskup6kb FOREIGN KEY (rental_id) REFERENCES public.rental (rental_id);
--
-- TOC entry 3744 (class 2606 OID 16480)
-- Name: friends_table fk62af6kydamwnr4nmjggm043vq; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.friends_table
ADD CONSTRAINT fk62af6kydamwnr4nmjggm043vq FOREIGN KEY (friend_id) REFERENCES public.account (account_id);
--
-- TOC entry 3741 (class 2606 OID 16485)
-- Name: fav_rental fk6tsxjh4c1c1q3atjew3gu5894; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.fav_rental
ADD CONSTRAINT fk6tsxjh4c1c1q3atjew3gu5894 FOREIGN KEY (account_id) REFERENCES public.account (account_id);
--
-- TOC entry 3747 (class 2606 OID 16495)
-- Name: rental_pic_urls fka3s615dh158g0v69ly4ly3a5b; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.rental_pic_urls
ADD CONSTRAINT fka3s615dh158g0v69ly4ly3a5b FOREIGN KEY (rental_id) REFERENCES public.rental (rental_id);
--
-- TOC entry 3745 (class 2606 OID 16505)
-- Name: friends_table fkb1gokokap499c6hqmmrnmi6rh; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.friends_table
ADD CONSTRAINT fkb1gokokap499c6hqmmrnmi6rh FOREIGN KEY (account_id) REFERENCES public.account (account_id);
--
-- TOC entry 3746 (class 2606 OID 16510)
-- Name: rental fkb2oywyfdhfppwhi3os4pqxgd5; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.rental
ADD CONSTRAINT fkb2oywyfdhfppwhi3os4pqxgd5 FOREIGN KEY (creator_id) REFERENCES public.account (account_id);
--
-- TOC entry 3740 (class 2606 OID 16515)
-- Name: account_yay fkets0f0cq42gqwu9k2m863qvob; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.account_yay
ADD CONSTRAINT fkets0f0cq42gqwu9k2m863qvob FOREIGN KEY (account_id) REFERENCES public.account (account_id);
--
-- TOC entry 3742 (class 2606 OID 16520)
-- Name: fav_rental fkl50993o2ia1m2cnvylqdwgld4; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.fav_rental
ADD CONSTRAINT fkl50993o2ia1m2cnvylqdwgld4 FOREIGN KEY (rental_id) REFERENCES public.rental (rental_id);
--
-- TOC entry 3739 (class 2606 OID 16525)
-- Name: account_tags fkp3bn2fkyg67xosnh8srrff7vn; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.account_tags
ADD CONSTRAINT fkp3bn2fkyg67xosnh8srrff7vn FOREIGN KEY (account_id) REFERENCES public.account (account_id);
--
-- TOC entry 3879 (class 0 OID 0)
-- Dependencies: 3
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT
ALL
ON SCHEMA public TO postgres;
GRANT ALL
ON SCHEMA public TO PUBLIC;
-- Completed on 2020-11-16 13:28:18
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,284 @@
-- Downloaded from: https://github.com/mostafacs/ecommerce-microservices-spring-reactive-webflux/blob/919ad2b751d095a3679b445ebad27b77e42b0cef/storage/migration/src/main/resources/flyway/migrations/m20190805__Base_Tables.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.7 (Ubuntu 10.7-0ubuntu0.18.04.1)
-- Dumped by pg_dump version 11.2 (Ubuntu 11.2-1.pgdg18.04+1)
-- Started on 2019-07-29 04:35:46 EET
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 client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 4 (class 2615 OID 24710)
-- Name: ecommerce; Type: SCHEMA; Schema: -; Owner: ecommerce
--
CREATE SCHEMA ecommerce;
ALTER SCHEMA ecommerce OWNER TO ecommerce;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 198 (class 1259 OID 16389)
-- Name: product_id_seq; Type: SEQUENCE; Schema: public; Owner: ecommerce
--
CREATE SEQUENCE ecommerce.product_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE ecommerce.product_id_seq OWNER TO ecommerce;
--
-- TOC entry 197 (class 1259 OID 16386)
-- Name: product; Type: TABLE; Schema: public; Owner: ecommerce
--
CREATE TABLE ecommerce.product (
id bigint DEFAULT nextval('ecommerce.product_id_seq'::regclass) NOT NULL,
title character varying(250),
sku character varying(150),
inventory_count integer
);
ALTER TABLE ecommerce.product OWNER TO ecommerce;
--
-- TOC entry 199 (class 1259 OID 24579)
-- Name: shopping_cart_id_seq; Type: SEQUENCE; Schema: public; Owner: ecommerce
--
CREATE SEQUENCE ecommerce.shopping_cart_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE ecommerce.shopping_cart_id_seq OWNER TO ecommerce;
--
-- TOC entry 201 (class 1259 OID 24583)
-- Name: shopping_cart; Type: TABLE; Schema: public; Owner: ecommerce
--
CREATE TABLE ecommerce.shopping_cart (
id bigint DEFAULT nextval('ecommerce.shopping_cart_id_seq'::regclass) NOT NULL,
total_quantity integer,
sub_total_price numeric(18,5),
total_shipping_cost numeric(18,0),
total_cost numeric,
user_id bigint
);
ALTER TABLE ecommerce.shopping_cart OWNER TO ecommerce;
--
-- TOC entry 200 (class 1259 OID 24581)
-- Name: shopping_cart_item_id_seq; Type: SEQUENCE; Schema: public; Owner: ecommerce
--
CREATE SEQUENCE ecommerce.shopping_cart_item_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE ecommerce.shopping_cart_item_id_seq OWNER TO ecommerce;
--
-- TOC entry 202 (class 1259 OID 24590)
-- Name: shopping_cart_item; Type: TABLE; Schema: public; Owner: ecommerce
--
CREATE TABLE ecommerce.shopping_cart_item (
id bigint DEFAULT nextval('ecommerce.shopping_cart_item_id_seq'::regclass) NOT NULL,
quantity integer,
unit_price numeric,
total_price numeric,
shipping_cost numeric,
product_id bigint,
shopping_cart_id bigint
);
ALTER TABLE ecommerce.shopping_cart_item OWNER TO ecommerce;
--
-- TOC entry 204 (class 1259 OID 24671)
-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: ecommerce
--
CREATE SEQUENCE ecommerce.user_id_seq
START WITH 0
INCREMENT BY 1
MINVALUE 0
NO MAXVALUE
CACHE 1;
ALTER TABLE ecommerce.user_id_seq OWNER TO ecommerce;
--
-- TOC entry 203 (class 1259 OID 24645)
-- Name: users; Type: TABLE; Schema: public; Owner: ecommerce
--
CREATE TABLE ecommerce.users (
id bigint DEFAULT nextval('ecommerce.user_id_seq'::regclass) NOT NULL,
first_name character varying(100),
last_name character varying(100),
create_date date,
update_date date,
last_login date,
email character varying(100),
password text
);
ALTER TABLE ecommerce.users OWNER TO ecommerce;
--
-- TOC entry 2969 (class 0 OID 0)
-- Dependencies: 198
-- Name: product_id_seq; Type: SEQUENCE SET; Schema: public; Owner: ecommerce
--
SELECT pg_catalog.setval('ecommerce.product_id_seq', 3, true);
--
-- TOC entry 2970 (class 0 OID 0)
-- Dependencies: 199
-- Name: shopping_cart_id_seq; Type: SEQUENCE SET; Schema: public; Owner: ecommerce
--
SELECT pg_catalog.setval('ecommerce.shopping_cart_id_seq', 24, true);
--
-- TOC entry 2971 (class 0 OID 0)
-- Dependencies: 200
-- Name: shopping_cart_item_id_seq; Type: SEQUENCE SET; Schema: public; Owner: ecommerce
--
SELECT pg_catalog.setval('ecommerce.shopping_cart_item_id_seq', 11, true);
--
-- TOC entry 2972 (class 0 OID 0)
-- Dependencies: 204
-- Name: user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: ecommerce
--
SELECT pg_catalog.setval('ecommerce.user_id_seq', 2, true);
--
-- TOC entry 2823 (class 2606 OID 24598)
-- Name: shopping_cart_item cart_item_pk; Type: CONSTRAINT; Schema: public; Owner: ecommerce
--
ALTER TABLE ONLY ecommerce.shopping_cart_item
ADD CONSTRAINT cart_item_pk PRIMARY KEY (id);
--
-- TOC entry 2821 (class 2606 OID 24606)
-- Name: shopping_cart cart_pk; Type: CONSTRAINT; Schema: public; Owner: ecommerce
--
ALTER TABLE ONLY ecommerce.shopping_cart
ADD CONSTRAINT cart_pk PRIMARY KEY (id);
--
-- TOC entry 2819 (class 2606 OID 16392)
-- Name: product product_pk; Type: CONSTRAINT; Schema: public; Owner: ecommerce
--
ALTER TABLE ONLY ecommerce.product
ADD CONSTRAINT product_pk PRIMARY KEY (id);
--
-- TOC entry 2827 (class 2606 OID 24649)
-- Name: users user_pk; Type: CONSTRAINT; Schema: public; Owner: ecommerce
--
ALTER TABLE ONLY ecommerce.users
ADD CONSTRAINT user_pk PRIMARY KEY (id);
--
-- TOC entry 2824 (class 1259 OID 24617)
-- Name: fki_cart_item_cart_fk; Type: INDEX; Schema: public; Owner: ecommerce
--
CREATE INDEX fki_cart_item_cart_fk ON ecommerce.shopping_cart_item USING btree (shopping_cart_id);
--
-- TOC entry 2825 (class 1259 OID 24604)
-- Name: fki_cart_item_product_fk; Type: INDEX; Schema: public; Owner: ecommerce
--
CREATE INDEX fki_cart_item_product_fk ON ecommerce.shopping_cart_item USING btree (product_id);
--
-- TOC entry 2833 (class 2606 OID 24612)
-- Name: shopping_cart_item cart_item_cart_fk; Type: FK CONSTRAINT; Schema: public; Owner: ecommerce
--
ALTER TABLE ONLY ecommerce.shopping_cart_item
ADD CONSTRAINT cart_item_cart_fk FOREIGN KEY (shopping_cart_id) REFERENCES ecommerce.shopping_cart(id);
--
-- TOC entry 2832 (class 2606 OID 24599)
-- Name: shopping_cart_item cart_item_product_fk; Type: FK CONSTRAINT; Schema: public; Owner: ecommerce
--
ALTER TABLE ONLY ecommerce.shopping_cart_item
ADD CONSTRAINT cart_item_product_fk FOREIGN KEY (product_id) REFERENCES ecommerce.product(id);
--
-- TOC entry 2831 (class 2606 OID 24650)
-- Name: shopping_cart user_fk; Type: FK CONSTRAINT; Schema: public; Owner: ecommerce
--
ALTER TABLE ONLY ecommerce.shopping_cart
ADD CONSTRAINT user_fk FOREIGN KEY (user_id) REFERENCES ecommerce.users(id);
-- Completed on 2019-07-29 04:35:50 EET
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+747
View File
@@ -0,0 +1,747 @@
-- Downloaded from: https://github.com/nxtrm/neanote/blob/5df6e89644d61dc346590d4cc87015944c628249/dbexport.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.4
-- Dumped by pg_dump version 16.4
-- Started on 2025-04-18 09:56:13
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;
--
-- TOC entry 2 (class 3079 OID 16403)
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
--
-- TOC entry 4930 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
--
-- TOC entry 867 (class 1247 OID 16426)
-- Name: note_type; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.note_type AS ENUM (
'memory',
'task',
'goal',
'event',
'habit',
'note'
);
ALTER TYPE public.note_type OWNER TO postgres;
--
-- TOC entry 242 (class 1255 OID 32768)
-- Name: cosine_similarity(double precision[], double precision[]); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.cosine_similarity(vec1 double precision[], vec2 double precision[]) RETURNS double precision
LANGUAGE plpgsql
AS $$
DECLARE
dot_product double precision := 0;
norm_a double precision := 0;
norm_b double precision := 0;
i int;
BEGIN
IF vec1 IS NULL OR vec2 IS NULL THEN
RETURN 0;
END IF;
FOR i IN array_lower(vec1, 1)..array_upper(vec1, 1) LOOP
dot_product := dot_product + (vec1[i] * vec2[i]);
norm_a := norm_a + (vec1[i] * vec1[i]);
norm_b := norm_b + (vec2[i] * vec2[i]);
END LOOP;
IF norm_a = 0 OR norm_b = 0 THEN
RETURN 0;
END IF;
RETURN dot_product / (sqrt(norm_a) * sqrt(norm_b));
END;
$$;
ALTER FUNCTION public.cosine_similarity(vec1 double precision[], vec2 double precision[]) OWNER TO postgres;
--
-- TOC entry 241 (class 1255 OID 24576)
-- Name: update_updated_at_column(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.update_updated_at_column() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$;
ALTER FUNCTION public.update_updated_at_column() OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 230 (class 1259 OID 73732)
-- Name: goalhistory; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.goalhistory (
goal_id uuid,
id uuid NOT NULL
);
ALTER TABLE public.goalhistory OWNER TO postgres;
--
-- TOC entry 221 (class 1259 OID 16501)
-- Name: goals; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.goals (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
note_id uuid,
completion_timestamp timestamp without time zone,
due_date timestamp without time zone
);
ALTER TABLE public.goals OWNER TO postgres;
--
-- TOC entry 224 (class 1259 OID 16575)
-- Name: habitcompletion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.habitcompletion (
habit_id uuid,
completion_date date
);
ALTER TABLE public.habitcompletion OWNER TO postgres;
--
-- TOC entry 223 (class 1259 OID 16563)
-- Name: habits; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.habits (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
note_id uuid,
reminder_time time without time zone,
streak integer DEFAULT 0,
repetition character varying(7)
);
ALTER TABLE public.habits OWNER TO postgres;
--
-- TOC entry 225 (class 1259 OID 16583)
-- Name: habittasks; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.habittasks (
habit_id uuid,
task_id uuid
);
ALTER TABLE public.habittasks OWNER TO postgres;
--
-- TOC entry 222 (class 1259 OID 16512)
-- Name: milestones; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.milestones (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
goal_id uuid,
description text,
ms_index integer,
completed boolean DEFAULT false
);
ALTER TABLE public.milestones OWNER TO postgres;
--
-- TOC entry 217 (class 1259 OID 16448)
-- Name: notes; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.notes (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid,
title character varying(100),
content text,
type public.note_type NOT NULL,
archived boolean DEFAULT false,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
vector double precision[]
);
ALTER TABLE public.notes OWNER TO postgres;
--
-- TOC entry 227 (class 1259 OID 16604)
-- Name: notetags; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.notetags (
note_id uuid NOT NULL,
tag_id uuid NOT NULL
);
ALTER TABLE public.notetags OWNER TO postgres;
--
-- TOC entry 219 (class 1259 OID 16476)
-- Name: subtasks; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.subtasks (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
task_id uuid,
description text,
completed boolean DEFAULT false,
st_index integer
);
ALTER TABLE public.subtasks OWNER TO postgres;
--
-- TOC entry 226 (class 1259 OID 16596)
-- Name: tags; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.tags (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying(50) NOT NULL,
color character varying(7) NOT NULL,
user_id uuid
);
ALTER TABLE public.tags OWNER TO postgres;
--
-- TOC entry 218 (class 1259 OID 16464)
-- Name: tasks; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.tasks (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
note_id uuid,
completed boolean DEFAULT false,
due_date timestamp without time zone,
completion_timestamp timestamp without time zone
);
ALTER TABLE public.tasks OWNER TO postgres;
--
-- TOC entry 220 (class 1259 OID 16490)
-- Name: taskstatistics; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.taskstatistics (
user_id uuid,
total_completed_tasks integer DEFAULT 0,
weekly_completed_tasks integer DEFAULT 0,
monthly_completed_tasks integer DEFAULT 0
);
ALTER TABLE public.taskstatistics OWNER TO postgres;
--
-- TOC entry 229 (class 1259 OID 57348)
-- Name: user_widgets; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.user_widgets (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
data_source_id uuid,
configuration json,
data_source_type character varying,
widget_id character varying,
title character varying
);
ALTER TABLE public.user_widgets OWNER TO postgres;
--
-- TOC entry 216 (class 1259 OID 16437)
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.users (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
username character varying(50) NOT NULL,
email character varying(100) NOT NULL,
password character varying(255) NOT NULL,
preferences json DEFAULT '{}'::json
);
ALTER TABLE public.users OWNER TO postgres;
--
-- TOC entry 228 (class 1259 OID 49156)
-- Name: widgets; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.widgets (
id uuid NOT NULL,
name character varying(100) NOT NULL,
description text,
allowed_data_sources public.note_type[]
);
ALTER TABLE public.widgets OWNER TO postgres;
--
-- TOC entry 4924 (class 0 OID 73732)
-- Dependencies: 230
-- Data for Name: goalhistory; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.goalhistory (goal_id, id) FROM stdin;
\.
--
-- TOC entry 4915 (class 0 OID 16501)
-- Dependencies: 221
-- Data for Name: goals; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.goals (id, note_id, completion_timestamp, due_date) FROM stdin;
\.
--
-- TOC entry 4918 (class 0 OID 16575)
-- Dependencies: 224
-- Data for Name: habitcompletion; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.habitcompletion (habit_id, completion_date) FROM stdin;
\.
--
-- TOC entry 4917 (class 0 OID 16563)
-- Dependencies: 223
-- Data for Name: habits; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.habits (id, note_id, reminder_time, streak, repetition) FROM stdin;
\.
--
-- TOC entry 4919 (class 0 OID 16583)
-- Dependencies: 225
-- Data for Name: habittasks; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.habittasks (habit_id, task_id) FROM stdin;
\.
--
-- TOC entry 4916 (class 0 OID 16512)
-- Dependencies: 222
-- Data for Name: milestones; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.milestones (id, goal_id, description, ms_index, completed) FROM stdin;
\.
--
-- TOC entry 4911 (class 0 OID 16448)
-- Dependencies: 217
-- Data for Name: notes; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.notes (id, user_id, title, content, type, archived, created_at, updated_at, vector) FROM stdin;
\.
--
-- TOC entry 4921 (class 0 OID 16604)
-- Dependencies: 227
-- Data for Name: notetags; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.notetags (note_id, tag_id) FROM stdin;
\.
--
-- TOC entry 4913 (class 0 OID 16476)
-- Dependencies: 219
-- Data for Name: subtasks; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.subtasks (id, task_id, description, completed, st_index) FROM stdin;
\.
--
-- TOC entry 4920 (class 0 OID 16596)
-- Dependencies: 226
-- Data for Name: tags; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.tags (id, name, color, user_id) FROM stdin;
\.
--
-- TOC entry 4912 (class 0 OID 16464)
-- Dependencies: 218
-- Data for Name: tasks; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.tasks (id, note_id, completed, due_date, completion_timestamp) FROM stdin;
\.
--
-- TOC entry 4914 (class 0 OID 16490)
-- Dependencies: 220
-- Data for Name: taskstatistics; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.taskstatistics (user_id, total_completed_tasks, weekly_completed_tasks, monthly_completed_tasks) FROM stdin;
\.
--
-- TOC entry 4923 (class 0 OID 57348)
-- Dependencies: 229
-- Data for Name: user_widgets; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.user_widgets (id, user_id, data_source_id, configuration, data_source_type, widget_id, title) FROM stdin;
\.
--
-- TOC entry 4910 (class 0 OID 16437)
-- Dependencies: 216
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.users (id, username, email, password, preferences) FROM stdin;
\.
--
-- TOC entry 4922 (class 0 OID 49156)
-- Dependencies: 228
-- Data for Name: widgets; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.widgets (id, name, description, allowed_data_sources) FROM stdin;
\.
--
-- TOC entry 4752 (class 2606 OID 73736)
-- Name: goalhistory goalhistory_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.goalhistory
ADD CONSTRAINT goalhistory_pkey PRIMARY KEY (id);
--
-- TOC entry 4736 (class 2606 OID 16506)
-- Name: goals goals_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.goals
ADD CONSTRAINT goals_pkey PRIMARY KEY (id);
--
-- TOC entry 4740 (class 2606 OID 16569)
-- Name: habits habits_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.habits
ADD CONSTRAINT habits_pkey PRIMARY KEY (id);
--
-- TOC entry 4738 (class 2606 OID 16520)
-- Name: milestones milestones_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.milestones
ADD CONSTRAINT milestones_pkey PRIMARY KEY (id);
--
-- TOC entry 4730 (class 2606 OID 16458)
-- Name: notes notes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.notes
ADD CONSTRAINT notes_pkey PRIMARY KEY (id);
--
-- TOC entry 4746 (class 2606 OID 16608)
-- Name: notetags notetags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.notetags
ADD CONSTRAINT notetags_pkey PRIMARY KEY (note_id, tag_id);
--
-- TOC entry 4734 (class 2606 OID 16484)
-- Name: subtasks subtasks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.subtasks
ADD CONSTRAINT subtasks_pkey PRIMARY KEY (id);
--
-- TOC entry 4742 (class 2606 OID 16603)
-- Name: tags tags_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tags
ADD CONSTRAINT tags_name_key UNIQUE (name);
--
-- TOC entry 4744 (class 2606 OID 16601)
-- Name: tags tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tags
ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
--
-- TOC entry 4732 (class 2606 OID 16470)
-- Name: tasks tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tasks
ADD CONSTRAINT tasks_pkey PRIMARY KEY (id);
--
-- TOC entry 4750 (class 2606 OID 57354)
-- Name: user_widgets user_widgets_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_widgets
ADD CONSTRAINT user_widgets_pkey PRIMARY KEY (id);
--
-- TOC entry 4726 (class 2606 OID 16447)
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_email_key UNIQUE (email);
--
-- TOC entry 4728 (class 2606 OID 16445)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- TOC entry 4748 (class 2606 OID 49162)
-- Name: widgets widgets_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.widgets
ADD CONSTRAINT widgets_pkey PRIMARY KEY (id);
--
-- TOC entry 4766 (class 2620 OID 24577)
-- Name: notes update_notes_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER update_notes_updated_at BEFORE UPDATE ON public.notes FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
--
-- TOC entry 4757 (class 2606 OID 16507)
-- Name: goals goals_note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.goals
ADD CONSTRAINT goals_note_id_fkey FOREIGN KEY (note_id) REFERENCES public.notes(id);
--
-- TOC entry 4760 (class 2606 OID 16578)
-- Name: habitcompletion habitcompletion_habit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.habitcompletion
ADD CONSTRAINT habitcompletion_habit_id_fkey FOREIGN KEY (habit_id) REFERENCES public.habits(id);
--
-- TOC entry 4759 (class 2606 OID 16570)
-- Name: habits habits_note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.habits
ADD CONSTRAINT habits_note_id_fkey FOREIGN KEY (note_id) REFERENCES public.notes(id);
--
-- TOC entry 4761 (class 2606 OID 16586)
-- Name: habittasks habittasks_habit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.habittasks
ADD CONSTRAINT habittasks_habit_id_fkey FOREIGN KEY (habit_id) REFERENCES public.habits(id);
--
-- TOC entry 4762 (class 2606 OID 16591)
-- Name: habittasks habittasks_task_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.habittasks
ADD CONSTRAINT habittasks_task_id_fkey FOREIGN KEY (task_id) REFERENCES public.tasks(id);
--
-- TOC entry 4758 (class 2606 OID 16521)
-- Name: milestones milestones_goal_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.milestones
ADD CONSTRAINT milestones_goal_id_fkey FOREIGN KEY (goal_id) REFERENCES public.goals(id);
--
-- TOC entry 4753 (class 2606 OID 16459)
-- Name: notes notes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.notes
ADD CONSTRAINT notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- TOC entry 4764 (class 2606 OID 16609)
-- Name: notetags notetags_note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.notetags
ADD CONSTRAINT notetags_note_id_fkey FOREIGN KEY (note_id) REFERENCES public.notes(id);
--
-- TOC entry 4765 (class 2606 OID 16614)
-- Name: notetags notetags_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.notetags
ADD CONSTRAINT notetags_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES public.tags(id);
--
-- TOC entry 4755 (class 2606 OID 16485)
-- Name: subtasks subtasks_task_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.subtasks
ADD CONSTRAINT subtasks_task_id_fkey FOREIGN KEY (task_id) REFERENCES public.tasks(id);
--
-- TOC entry 4763 (class 2606 OID 16620)
-- Name: tags tags_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tags
ADD CONSTRAINT tags_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- TOC entry 4754 (class 2606 OID 16471)
-- Name: tasks tasks_note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tasks
ADD CONSTRAINT tasks_note_id_fkey FOREIGN KEY (note_id) REFERENCES public.notes(id);
--
-- TOC entry 4756 (class 2606 OID 16496)
-- Name: taskstatistics taskstatistics_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.taskstatistics
ADD CONSTRAINT taskstatistics_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
-- Completed on 2025-04-18 09:56:13
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,436 @@
-- Downloaded from: https://github.com/oknosoft/windowbuilder-planning/blob/0861330ad94cd7a4755c8ba5ab798d2baf4006f6/server/keys/init/pg.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.8
-- Dumped by pg_dump version 14.8
-- Started on 2023-08-12 22:07:45 MSK
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET escape_string_warning = off;
SET row_security = off;
--
-- TOC entry 2 (class 3079 OID 2899788)
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
--
-- TOC entry 3404 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
--
-- TOC entry 879 (class 1247 OID 3176553)
-- Name: key_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.key_type AS ENUM (
'order',
'product',
'layer',
'profile',
'filling',
'glass',
'glunit',
'layout',
'other'
);
--
-- TOC entry 861 (class 1247 OID 6144761)
-- Name: keys_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.keys_type AS (
obj uuid,
specimen integer,
elm integer,
region integer
);
--
-- TOC entry 885 (class 1247 OID 3698031)
-- Name: prod_row; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.prod_row AS (
characteristic uuid,
quantity integer
);
--
-- TOC entry 882 (class 1247 OID 3556323)
-- Name: qinfo_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.qinfo_type AS (
abonent uuid,
year integer,
branch uuid,
barcode bigint,
ref uuid,
calc_order uuid,
characteristic uuid,
presentation character varying(200),
specimen integer,
elm integer,
region integer,
type public.key_type,
leading_product uuid
);
--
-- TOC entry 888 (class 1247 OID 5825217)
-- Name: refs; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.refs AS ENUM (
'doc.calc_order',
'doc.planning_event',
'doc.work_centers_task',
'doc.work_centers_performance',
'doc.purchase_order',
'doc.debit_cash_order',
'doc.credit_cash_order',
'doc.credit_card_order',
'doc.debit_bank_order',
'doc.credit_bank_order',
'doc.selling',
'doc.purchase',
'doc.nom_prices_setup'
);
--
-- TOC entry 253 (class 1255 OID 3558639)
-- Name: qinfo(character varying); Type: FUNCTION; Schema: public; Owner: -
--
-- FUNCTION: public.qinfo(character varying)
-- DROP FUNCTION IF EXISTS public.qinfo(character varying);
CREATE OR REPLACE FUNCTION public.qinfo(code character varying) RETURNS qinfo_type
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
declare
tmp qinfo_type;
keys_row keys%ROWTYPE;
cx_row characteristics%ROWTYPE;
order_row calc_orders%ROWTYPE;
icode bigint;
ucode uuid;
begin
/* ищем запись в keys */
if(char_length(code) = 13) then
code = substring(code, 1, 12);
end if;
if char_length(code) = 12 then
icode = code;
SELECT * INTO keys_row FROM keys WHERE barcode=icode;
elseif char_length(code) = 36 then
ucode = code;
SELECT * INTO keys_row FROM keys WHERE ref=ucode;
end if;
/* подклеиваем заказ и прочую инфу */
if keys_row.type is null then
RAISE NOTICE 'null';
elseif keys_row.type = 'order' then
SELECT * INTO order_row FROM calc_orders WHERE ref=keys_row.obj;
else
SELECT * INTO cx_row FROM characteristics WHERE ref=keys_row.obj;
SELECT * INTO order_row FROM calc_orders WHERE ref=cx_row.calc_order;
end if;
tmp.abonent = order_row.abonent;
tmp.year = order_row.year;
tmp.branch = order_row.branch;
tmp.calc_order = order_row.ref;
tmp.characteristic = cx_row.ref;
tmp.leading_product = cx_row.leading_product;
tmp.barcode = keys_row.barcode;
tmp.ref = keys_row.ref;
tmp.specimen = keys_row.specimen;
tmp.elm = keys_row.elm;
tmp.region = keys_row.region;
tmp.type = keys_row.type;
if keys_row.type = 'order' then
tmp.presentation = format('%s от %s', order_row.number_doc, order_row.date);
else
tmp.presentation = cx_row.name;
end if;
return tmp;
end
$BODY$;
ALTER FUNCTION public.qinfo(character varying)
OWNER TO postgres;
SET default_table_access_method = heap;
--
-- TOC entry 231 (class 1259 OID 6296209)
-- Name: areg_needs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.areg_needs (
register uuid NOT NULL,
register_type public.refs NOT NULL,
row_num bigint NOT NULL,
period timestamp without time zone,
sign smallint DEFAULT 1,
calc_order uuid,
nom uuid,
characteristic uuid,
stage uuid,
planing_key uuid,
quantity numeric(15,3) DEFAULT 0
);
--
-- TOC entry 3405 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.register; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.register IS 'Регистратор';
--
-- TOC entry 3406 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.register_type; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.register_type IS 'Тип регистратора';
--
-- TOC entry 3407 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.row_num; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.row_num IS 'Номер строки';
--
-- TOC entry 3408 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.period; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.period IS 'Период';
--
-- TOC entry 3409 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.nom; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.nom IS 'Номенклатура';
--
-- TOC entry 3410 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.characteristic; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.characteristic IS 'Характеристика';
--
-- TOC entry 3411 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.stage; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.stage IS 'Этап производства';
--
-- TOC entry 3412 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.planing_key; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.planing_key IS 'Ключ планирования';
--
-- TOC entry 3413 (class 0 OID 0)
-- Dependencies: 231
-- Name: COLUMN areg_needs.quantity; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.areg_needs.quantity IS 'Количество';
--
-- TOC entry 227 (class 1259 OID 3061481)
-- Name: calc_orders; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.calc_orders (
ref uuid NOT NULL,
abonent uuid,
branch uuid,
year integer,
date timestamp without time zone,
number_doc character(11),
partner uuid,
organization uuid,
author uuid,
department uuid,
production json
);
--
-- TOC entry 225 (class 1259 OID 2900139)
-- Name: characteristics; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.characteristics (
ref uuid NOT NULL,
calc_order uuid,
leading_product uuid,
name character varying(200)
);
--
-- TOC entry 224 (class 1259 OID 2899806)
-- Name: keys; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.keys (
ref uuid DEFAULT public.uuid_generate_v1mc() NOT NULL,
obj uuid NOT NULL,
specimen integer DEFAULT 1,
elm integer DEFAULT 0,
region integer DEFAULT 0,
barcode bigint DEFAULT 0,
type public.key_type
);
--
-- TOC entry 226 (class 1259 OID 2900714)
-- Name: settings; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.settings (
param character varying(100) NOT NULL,
value json NOT NULL
);
--
-- TOC entry 3247 (class 1259 OID 3061357)
-- Name: address; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX address ON public.keys USING btree (obj, specimen, elm, region);
--
-- TOC entry 3258 (class 2606 OID 6296217)
-- Name: areg_needs areg_needs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.areg_needs
ADD CONSTRAINT areg_needs_pkey PRIMARY KEY (register, register_type, row_num);
--
-- TOC entry 3252 (class 2606 OID 2900143)
-- Name: characteristics characteristics_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.characteristics
ADD CONSTRAINT characteristics_pkey PRIMARY KEY (ref);
--
-- TOC entry 3250 (class 2606 OID 2899811)
-- Name: keys keys_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.keys
ADD CONSTRAINT keys_pkey PRIMARY KEY (ref);
--
-- TOC entry 3256 (class 2606 OID 3061485)
-- Name: calc_orders orders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.calc_orders
ADD CONSTRAINT orders_pkey PRIMARY KEY (ref);
--
-- TOC entry 3254 (class 2606 OID 2900720)
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.settings
ADD CONSTRAINT settings_pkey PRIMARY KEY (param);
--
-- TOC entry 3248 (class 1259 OID 3494689)
-- Name: barcode; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX barcode ON public.keys USING btree (barcode);
--
-- TOC entry 3259 (class 2606 OID 3061494)
-- Name: characteristics order; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.characteristics
ADD CONSTRAINT "order" FOREIGN KEY (calc_order) REFERENCES public.calc_orders(ref) NOT VALID;
-- Completed on 2023-08-12 22:07:45 MSK
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,152 @@
-- Downloaded from: https://github.com/openeventdatabase/backend/blob/656c3fd41413d1a95b3d8fbec4bd01b31642c2ce/setup.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.3
-- Dumped by pg_dump version 9.5.3
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "postgis";
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: events; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE events (
events_id uuid DEFAULT uuid_generate_v4(),
createdate timestamp without time zone DEFAULT now(),
lastupdate timestamp without time zone,
events_type text,
events_what text,
events_when tstzrange,
events_geo text,
events_tags jsonb
);
CREATE TABLE events_deleted (
events_id uuid,
createdate timestamp without time zone,
lastupdate timestamp without time zone,
events_type text,
events_what text,
events_when tstzrange,
events_geo text,
events_tags jsonb
);
--
-- Name: geo; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE geo (
geom geometry(Geometry,4326),
hash text,
geom_center geometry(Point,4326),
idx geometry
);
--
-- Name: geo_hash_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY geo
ADD CONSTRAINT geo_hash_key UNIQUE (hash);
--
-- Name: events_idx_antidup; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX events_idx_antidup ON events USING btree (events_geo, events_what, events_when);
--
-- Name: events_idx_id; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX events_idx_id ON events USING btree (events_id);
--
-- Name: events_idx_lastupdate; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_idx_lastupdate ON events USING btree (lastupdate);
--
-- Name: events_idx_what; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_idx_what ON events USING spgist (events_what);
--
-- Name: events_idx_when; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_idx_when ON events USING spgist (events_when);
--
-- Name: geo_geom; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX geo_geom ON geo USING gist (geom);
--
-- Name: geo_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX geo_idx ON geo USING gist (idx);
--
-- Name: events_lastupdate_trigger; Type: TRIGGER; Schema: public; Owner: -
--
CREATE FUNCTION events_lastupdate() RETURNS trigger AS $$
BEGIN
NEW.lastupdate := NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER events_lastupdate_trigger BEFORE INSERT OR UPDATE ON events FOR EACH ROW EXECUTE PROCEDURE events_lastupdate();
--
-- Name: geo_pk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY events
ADD CONSTRAINT geo_pk FOREIGN KEY (events_geo) REFERENCES geo(hash);
--
-- PostgreSQL database dump complete
--
CREATE INDEX events_idx_where_osm ON events USING spgist ((events_tags->>'where:osm')) WHERE events_tags ? 'where:osm';
CREATE INDEX events_idx_where_wikidata ON events USING spgist ((events_tags->>'where:wikidata')) WHERE events_tags ? 'where:wikidata';
File diff suppressed because it is too large Load Diff
+358
View File
@@ -0,0 +1,358 @@
-- Downloaded from: https://github.com/oslabs-beta/ditto/blob/fa80cb2429f0de54951b6580ef893b2ed08ac698/dittoDB2.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.1
-- Dumped by pg_dump version 16.2
-- Started on 2024-06-05 19:19:25
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;
--
-- TOC entry 858 (class 1247 OID 16517)
-- Name: status_enum; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.status_enum AS ENUM (
'Failed',
'Success',
'Pending'
);
--
-- TOC entry 223 (class 1255 OID 16998)
-- Name: delete_column_value(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.delete_column_value() RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE projects SET code = NULL, code_timestamp = NULL WHERE code_timestamp < NOW() - INTERVAL '1 hour';
END;
$$;
--
-- TOC entry 228 (class 1255 OID 16996)
-- Name: update_timestamp(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$BEGIN
IF NEW.code IS NOT NULL THEN
NEW.code_timestamp := CURRENT_TIMESTAMP;
ELSE
NEW.code_timestamp := NULL;
END IF;
RETURN NEW;
END;
$$;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 218 (class 1259 OID 16487)
-- Name: databases; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.databases (
db_id integer NOT NULL,
date_created timestamp with time zone DEFAULT timezone('America/New_York'::text, date_trunc('second'::text, now())) NOT NULL,
connection_string character varying NOT NULL,
migration_id integer[]
);
--
-- TOC entry 217 (class 1259 OID 16486)
-- Name: databases_db_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.databases_db_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- TOC entry 4350 (class 0 OID 0)
-- Dependencies: 217
-- Name: databases_db_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.databases_db_id_seq OWNED BY public.databases.db_id;
--
-- TOC entry 216 (class 1259 OID 16476)
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users (
user_id integer NOT NULL,
username character varying NOT NULL,
password character varying NOT NULL,
date_created timestamp with time zone DEFAULT timezone('America/New_York'::text, date_trunc('second'::text, now())) NOT NULL
);
--
-- TOC entry 215 (class 1259 OID 16475)
-- Name: users_user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.users_user_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- TOC entry 4351 (class 0 OID 0)
-- Dependencies: 215
-- Name: users_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.users_user_id_seq OWNED BY public.users.user_id;
--
-- TOC entry 219 (class 1259 OID 16510)
-- Name: migration_logs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.migration_logs (
migration_id integer DEFAULT nextval('public.users_user_id_seq'::regclass) NOT NULL,
user_id integer NOT NULL,
date_created timestamp with time zone DEFAULT timezone('America/New_York'::text, date_trunc('second'::text, now())) NOT NULL,
database_id integer NOT NULL,
description character varying,
status public.status_enum DEFAULT 'Pending'::public.status_enum,
script character varying,
checksum character varying,
executed_at character varying,
version character varying
);
--
-- TOC entry 222 (class 1259 OID 16813)
-- Name: project_db; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.project_db (
project_db_id integer DEFAULT nextval('public.databases_db_id_seq'::regclass) NOT NULL,
project_id integer,
db_id integer,
db_name character varying
);
--
-- TOC entry 221 (class 1259 OID 16786)
-- Name: projects; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.projects (
date_created timestamp with time zone DEFAULT timezone('America/New_York'::text, date_trunc('second'::text, now())),
project_name character varying,
project_id integer DEFAULT nextval('public.databases_db_id_seq'::regclass) NOT NULL,
owner integer,
code character varying,
code_timestamp timestamp with time zone
);
--
-- TOC entry 220 (class 1259 OID 16778)
-- Name: user_projects; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.user_projects (
user_project_id character varying DEFAULT nextval('public.databases_db_id_seq'::regclass) NOT NULL,
project_name character varying,
user_id integer,
project_id integer,
role character varying,
date_joined timestamp with time zone DEFAULT timezone('America/New_York'::text, date_trunc('second'::text, now()))
);
--
-- TOC entry 4169 (class 2604 OID 16490)
-- Name: databases db_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.databases ALTER COLUMN db_id SET DEFAULT nextval('public.databases_db_id_seq'::regclass);
--
-- TOC entry 4167 (class 2604 OID 16479)
-- Name: users user_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users ALTER COLUMN user_id SET DEFAULT nextval('public.users_user_id_seq'::regclass);
--
-- TOC entry 4182 (class 2606 OID 16624)
-- Name: databases connection_string; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.databases
ADD CONSTRAINT connection_string UNIQUE (connection_string);
--
-- TOC entry 4184 (class 2606 OID 16492)
-- Name: databases databases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.databases
ADD CONSTRAINT databases_pkey PRIMARY KEY (db_id);
--
-- TOC entry 4186 (class 2606 OID 16515)
-- Name: migration_logs migration_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.migration_logs
ADD CONSTRAINT migration_logs_pkey PRIMARY KEY (migration_id);
--
-- TOC entry 4192 (class 2606 OID 16821)
-- Name: project_db project_db_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_db
ADD CONSTRAINT project_db_pkey PRIMARY KEY (project_db_id);
--
-- TOC entry 4190 (class 2606 OID 16802)
-- Name: projects projects_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.projects
ADD CONSTRAINT projects_pkey PRIMARY KEY (project_id);
--
-- TOC entry 4188 (class 2606 OID 16785)
-- Name: user_projects user_projects_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_projects
ADD CONSTRAINT user_projects_pkey PRIMARY KEY (user_project_id);
--
-- TOC entry 4180 (class 2606 OID 16481)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (user_id);
--
-- TOC entry 4199 (class 2620 OID 16997)
-- Name: projects set_timestamp; Type: TRIGGER; Schema: public; Owner: -
--
CREATE TRIGGER set_timestamp BEFORE INSERT OR UPDATE ON public.projects FOR EACH ROW EXECUTE FUNCTION public.update_timestamp();
--
-- TOC entry 4197 (class 2606 OID 16827)
-- Name: project_db db_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_db
ADD CONSTRAINT db_id_fkey FOREIGN KEY (db_id) REFERENCES public.databases(db_id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- TOC entry 4193 (class 2606 OID 16529)
-- Name: migration_logs migration_logs_database_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.migration_logs
ADD CONSTRAINT migration_logs_database_id_fkey FOREIGN KEY (database_id) REFERENCES public.databases(db_id) NOT VALID;
--
-- TOC entry 4194 (class 2606 OID 16524)
-- Name: migration_logs migration_logs_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.migration_logs
ADD CONSTRAINT migration_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) NOT VALID;
--
-- TOC entry 4198 (class 2606 OID 16822)
-- Name: project_db project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_db
ADD CONSTRAINT project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(project_id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- TOC entry 4195 (class 2606 OID 16832)
-- Name: user_projects project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_projects
ADD CONSTRAINT project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(project_id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- TOC entry 4196 (class 2606 OID 16803)
-- Name: user_projects user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_projects
ADD CONSTRAINT user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- TOC entry 4343 (class 0 OID 16487)
-- Dependencies: 218
-- Name: databases; Type: ROW SECURITY; Schema: public; Owner: -
--
ALTER TABLE public.databases ENABLE ROW LEVEL SECURITY;
-- Completed on 2024-06-05 19:19:28
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1,597 @@
-- Downloaded from: https://github.com/paulshriner/fcc-rd-cert/blob/f6c9c03198f143fd6d3e8aa229d11927cf2edbe1/celestial-bodies/universe.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.17 (Ubuntu 12.17-1.pgdg22.04+1)
-- Dumped by pg_dump version 12.17 (Ubuntu 12.17-1.pgdg22.04+1)
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;
DROP DATABASE universe;
--
-- Name: universe; Type: DATABASE; Schema: -; Owner: freecodecamp
--
CREATE DATABASE universe WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'C.UTF-8';
ALTER DATABASE universe OWNER TO freecodecamp;
\connect universe
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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: asteroids; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.asteroids (
asteroids_id integer NOT NULL,
name character varying,
description text NOT NULL,
length real NOT NULL
);
ALTER TABLE public.asteroids OWNER TO freecodecamp;
--
-- Name: asteroids_asteroids_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.asteroids_asteroids_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.asteroids_asteroids_id_seq OWNER TO freecodecamp;
--
-- Name: asteroids_asteroids_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.asteroids_asteroids_id_seq OWNED BY public.asteroids.asteroids_id;
--
-- Name: galaxy; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.galaxy (
galaxy_id integer NOT NULL,
name character varying,
description text,
has_stars boolean NOT NULL,
has_planets boolean NOT NULL
);
ALTER TABLE public.galaxy OWNER TO freecodecamp;
--
-- Name: galaxy_galaxy_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.galaxy_galaxy_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.galaxy_galaxy_id_seq OWNER TO freecodecamp;
--
-- Name: galaxy_galaxy_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.galaxy_galaxy_id_seq OWNED BY public.galaxy.galaxy_id;
--
-- Name: moon; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.moon (
moon_id integer NOT NULL,
name character varying,
description text,
distance_from_planet integer NOT NULL,
is_spherical boolean NOT NULL,
planet_id integer NOT NULL
);
ALTER TABLE public.moon OWNER TO freecodecamp;
--
-- Name: moon_moon_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.moon_moon_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.moon_moon_id_seq OWNER TO freecodecamp;
--
-- Name: moon_moon_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.moon_moon_id_seq OWNED BY public.moon.moon_id;
--
-- Name: moon_planet_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.moon_planet_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.moon_planet_id_seq OWNER TO freecodecamp;
--
-- Name: moon_planet_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.moon_planet_id_seq OWNED BY public.moon.planet_id;
--
-- Name: planet; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.planet (
planet_id integer NOT NULL,
name character varying,
description text,
has_life boolean NOT NULL,
distance_from_earth integer NOT NULL,
gravity numeric,
star_id integer NOT NULL
);
ALTER TABLE public.planet OWNER TO freecodecamp;
--
-- Name: planet_planet_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.planet_planet_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.planet_planet_id_seq OWNER TO freecodecamp;
--
-- Name: planet_planet_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.planet_planet_id_seq OWNED BY public.planet.planet_id;
--
-- Name: planet_star_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.planet_star_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.planet_star_id_seq OWNER TO freecodecamp;
--
-- Name: planet_star_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.planet_star_id_seq OWNED BY public.planet.star_id;
--
-- Name: star; Type: TABLE; Schema: public; Owner: freecodecamp
--
CREATE TABLE public.star (
star_id integer NOT NULL,
name character varying,
description text,
length numeric NOT NULL,
is_spherical boolean NOT NULL,
galaxy_id integer NOT NULL
);
ALTER TABLE public.star OWNER TO freecodecamp;
--
-- Name: star_galaxy_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.star_galaxy_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.star_galaxy_id_seq OWNER TO freecodecamp;
--
-- Name: star_galaxy_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.star_galaxy_id_seq OWNED BY public.star.galaxy_id;
--
-- Name: star_star_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--
CREATE SEQUENCE public.star_star_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.star_star_id_seq OWNER TO freecodecamp;
--
-- Name: star_star_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--
ALTER SEQUENCE public.star_star_id_seq OWNED BY public.star.star_id;
--
-- Name: asteroids asteroids_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.asteroids ALTER COLUMN asteroids_id SET DEFAULT nextval('public.asteroids_asteroids_id_seq'::regclass);
--
-- Name: galaxy galaxy_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.galaxy ALTER COLUMN galaxy_id SET DEFAULT nextval('public.galaxy_galaxy_id_seq'::regclass);
--
-- Name: moon moon_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.moon ALTER COLUMN moon_id SET DEFAULT nextval('public.moon_moon_id_seq'::regclass);
--
-- Name: moon planet_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.moon ALTER COLUMN planet_id SET DEFAULT nextval('public.moon_planet_id_seq'::regclass);
--
-- Name: planet planet_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.planet ALTER COLUMN planet_id SET DEFAULT nextval('public.planet_planet_id_seq'::regclass);
--
-- Name: planet star_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.planet ALTER COLUMN star_id SET DEFAULT nextval('public.planet_star_id_seq'::regclass);
--
-- Name: star star_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.star ALTER COLUMN star_id SET DEFAULT nextval('public.star_star_id_seq'::regclass);
--
-- Name: star galaxy_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.star ALTER COLUMN galaxy_id SET DEFAULT nextval('public.star_galaxy_id_seq'::regclass);
--
-- Data for Name: asteroids; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
INSERT INTO public.asteroids VALUES (1, '16 Psyche', '16 Psyche is named after the Greek goddess of soul. The 16 in its name refers to the fact that it was the sixteenth asteroid discovered.', 220);
INSERT INTO public.asteroids VALUES (2, 'Dimorphos', 'Dimorphos is part of a binary system of asteroids. It orbits around a slightly larger asteroid named Didymos and has a near-Earth orbit.', 0.177);
INSERT INTO public.asteroids VALUES (3, 'Bennu', 'Bennu, or more accurately, 101955 Bennu is one of the most important asteroids out there.', 0.49);
--
-- Data for Name: galaxy; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
INSERT INTO public.galaxy VALUES (1, 'Milky Way', 'The Milky Way is the galaxy that includes the Solar System, with the name describing the galaxy''s appearance from Earth.', true, true);
INSERT INTO public.galaxy VALUES (2, 'Andromeda', 'The Andromeda Galaxy is a barred spiral galaxy and is the nearest major galaxy to the Milky Way.', true, true);
INSERT INTO public.galaxy VALUES (3, 'Antennae', 'The Antennae Galaxies are a pair of interacting galaxies in the constellation Corvus.', true, true);
INSERT INTO public.galaxy VALUES (4, 'NGC 4622', 'NGC 4622 is a face-on unbarred spiral galaxy with a very prominent ring structure located in the constellation Centaurus.', true, true);
INSERT INTO public.galaxy VALUES (5, 'NGC 6822', 'NGC 6822 is a barred irregular galaxy approximately 1.6 million light-years away in the constellation Sagittarius.', true, true);
INSERT INTO public.galaxy VALUES (6, 'NGC 2537', 'NGC 2537 is a blue compact dwarf galaxy in the constellation Lynx, located around 3 degrees NNW of 31 Lyncis.', true, true);
--
-- Data for Name: moon; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
INSERT INTO public.moon VALUES (1, 'Moon', 'The Moon is Earth''s only natural satellite.', 384399, true, 3);
INSERT INTO public.moon VALUES (2, 'Phobos', 'Phobos is the innermost and larger of the two natural satellites of Mars.', 6000, false, 4);
INSERT INTO public.moon VALUES (3, 'Deimos', 'Deimos is the smaller and outer of the two natural satellites of Mars.', 23460, false, 4);
INSERT INTO public.moon VALUES (4, 'Metis', 'Metis is Jupiter''s closest moon.', 128000, false, 5);
INSERT INTO public.moon VALUES (5, 'Adrastea', 'Adrastea is Jupiter''s second closest moon.', 129000, false, 5);
INSERT INTO public.moon VALUES (6, 'Amalthea', 'Amalthea is Jupiter''s third closest moon.', 181400, false, 5);
INSERT INTO public.moon VALUES (7, 'Thebe', 'Thebe is Jupiter''s fourth closest moon.', 221900, false, 5);
INSERT INTO public.moon VALUES (8, 'Pan', 'Pan is the innermost named moon of Saturn.', 133600, false, 6);
INSERT INTO public.moon VALUES (9, 'Daphnis', 'Daphnis is an inner satellite of Saturn.', 136500, false, 6);
INSERT INTO public.moon VALUES (10, 'Atlas', 'Atlas is an inner satellite of Saturn.', 137700, false, 6);
INSERT INTO public.moon VALUES (11, 'Prometheus', 'Prometheus is an inner satellite of Saturn.', 139400, false, 6);
INSERT INTO public.moon VALUES (12, 'Cordelia', 'Cordelia is the innermost known moon of Uranus.', 49800, false, 7);
INSERT INTO public.moon VALUES (13, 'Ophelia', 'Ophelia is a moon of Uranus.', 53800, false, 7);
INSERT INTO public.moon VALUES (14, 'Bianca', 'Bianca is an inner satellite of Uranus.', 59200, false, 7);
INSERT INTO public.moon VALUES (15, 'Cressida', 'Cressida is an inner satellite of Uranus.', 61800, false, 7);
INSERT INTO public.moon VALUES (16, 'Naiad', 'Naiad is the innermost satellite of Neptune and the nearest to the center of any gas giant.', 48224, false, 8);
INSERT INTO public.moon VALUES (17, 'Thalassa', 'Thalassa is the second-innermost satellite of Neptune.', 50074, false, 8);
INSERT INTO public.moon VALUES (18, 'Charon', 'Charon is the largest known natural satellite of Pluto.', 19570, true, 9);
INSERT INTO public.moon VALUES (19, 'Styx', 'Styx is a small natural satellite of Pluto.', 42000, false, 9);
INSERT INTO public.moon VALUES (20, 'Nix', 'Nix is a natural satellite of Pluto.', 48708, false, 9);
--
-- Data for Name: planet; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
INSERT INTO public.planet VALUES (1, 'Mercury', 'Mercury is the closest planet to the Sun.', false, 91691000, 3.72, 1);
INSERT INTO public.planet VALUES (2, 'Venus', 'Venus is the second planet from the Sun and the third brightest object in Earth''s sky.', false, 41400000, 8.82, 1);
INSERT INTO public.planet VALUES (3, 'Earth', 'Earth is the third planet from the Sun and largest of the terrestrial planets.', true, 0, 9.8, 1);
INSERT INTO public.planet VALUES (4, 'Mars', 'Mars is the fourth planet from the Sun and last of the terrestrial planets.', false, 78340000, 3.63, 1);
INSERT INTO public.planet VALUES (5, 'Jupiter', 'Named after the Roman king of the gods, Jupiter is fitting of its name.', false, 550390000, 24.79, 1);
INSERT INTO public.planet VALUES (6, 'Saturn', 'Saturn is the sixth planet from the Sun and second largest planet of the Solar System in terms of diameter and mass.', false, 119666000, 10.44, 1);
INSERT INTO public.planet VALUES (7, 'Uranus', 'Uranus, named after the the father of the Roman god Saturn.', false, 264561000, 8.69, 1);
INSERT INTO public.planet VALUES (8, 'Neptune', 'Neptune is the eighth planet from the Sun and last of the known planets.', false, 427306000, 11.15, 1);
INSERT INTO public.planet VALUES (9, 'Pluto', 'Pluto is a dwarf planet in the Solar System.', false, 590000000, 0.658, 1);
INSERT INTO public.planet VALUES (10, 'Ceres', 'Discovered in 1801, it was considered a planet for a year.', false, 239356593, 0.284, 2);
INSERT INTO public.planet VALUES (11, 'Haumea', 'Haumea is the fastest rotating dwarf planet with the most interesting/controversial shape.', false, 766000000, 0.441, 3);
INSERT INTO public.planet VALUES (12, 'Eris', 'Eris is the most distant dwarf planet, located beyond the orbit of Neptune.', false, 142000000, 0.89, 4);
--
-- Data for Name: star; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--
INSERT INTO public.star VALUES (1, 'Sun', 'The Sun is the star at the centre of the Solar System.', 1392684, true, 1);
INSERT INTO public.star VALUES (2, 'Alpha Centauri', 'Alpha Centauri is a triple star system in the southern constellation of Centaurus.', 78200000000000, true, 1);
INSERT INTO public.star VALUES (3, 'Sigma Octantis', 'Sigma Octantis is a solitary star in the Octans constellation that forms the pole star of the Southern Hemisphere.', 6110400, true, 1);
INSERT INTO public.star VALUES (4, 'Mira', 'Mira is a red-giant star.', 231072000, true, 1);
INSERT INTO public.star VALUES (5, 'Sirius', 'Sirius is the brightest star in the night sky.', 1192728, true, 1);
INSERT INTO public.star VALUES (6, 'Barnard''s Star', 'Barnard''s Star is a small red dwarf star in the constellation of Ophiuchus.', 130012, true, 1);
--
-- Name: asteroids_asteroids_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.asteroids_asteroids_id_seq', 3, true);
--
-- Name: galaxy_galaxy_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.galaxy_galaxy_id_seq', 6, true);
--
-- Name: moon_moon_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.moon_moon_id_seq', 20, true);
--
-- Name: moon_planet_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.moon_planet_id_seq', 1, false);
--
-- Name: planet_planet_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.planet_planet_id_seq', 12, true);
--
-- Name: planet_star_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.planet_star_id_seq', 1, false);
--
-- Name: star_galaxy_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.star_galaxy_id_seq', 1, false);
--
-- Name: star_star_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--
SELECT pg_catalog.setval('public.star_star_id_seq', 6, true);
--
-- Name: asteroids asteroids_name_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.asteroids
ADD CONSTRAINT asteroids_name_key UNIQUE (name);
--
-- Name: asteroids asteroids_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.asteroids
ADD CONSTRAINT asteroids_pkey PRIMARY KEY (asteroids_id);
--
-- Name: galaxy galaxy_name_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.galaxy
ADD CONSTRAINT galaxy_name_key UNIQUE (name);
--
-- Name: galaxy galaxy_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.galaxy
ADD CONSTRAINT galaxy_pkey PRIMARY KEY (galaxy_id);
--
-- Name: moon moon_name_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.moon
ADD CONSTRAINT moon_name_key UNIQUE (name);
--
-- Name: moon moon_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.moon
ADD CONSTRAINT moon_pkey PRIMARY KEY (moon_id);
--
-- Name: planet planet_name_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.planet
ADD CONSTRAINT planet_name_key UNIQUE (name);
--
-- Name: planet planet_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.planet
ADD CONSTRAINT planet_pkey PRIMARY KEY (planet_id);
--
-- Name: star star_name_key; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.star
ADD CONSTRAINT star_name_key UNIQUE (name);
--
-- Name: star star_pkey; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.star
ADD CONSTRAINT star_pkey PRIMARY KEY (star_id);
--
-- Name: moon moon_planet_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.moon
ADD CONSTRAINT moon_planet_id_fkey FOREIGN KEY (planet_id) REFERENCES public.planet(planet_id);
--
-- Name: planet planet_star_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.planet
ADD CONSTRAINT planet_star_id_fkey FOREIGN KEY (star_id) REFERENCES public.star(star_id);
--
-- Name: star star_galaxy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--
ALTER TABLE ONLY public.star
ADD CONSTRAINT star_galaxy_id_fkey FOREIGN KEY (galaxy_id) REFERENCES public.galaxy(galaxy_id);
--
-- PostgreSQL database dump complete
--
+603
View File
@@ -0,0 +1,603 @@
-- Downloaded from: https://github.com/qqtati/diplom/blob/2be609833a470cdb3fb4a6e8f68732c779b049b6/create.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 17.4
-- Dumped by pg_dump version 17.2 (Homebrew)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: pg_database_owner
--
CREATE SCHEMA IF NOT EXISTS public;
ALTER SCHEMA public OWNER TO pg_database_owner;
--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: pg_database_owner
--
COMMENT ON SCHEMA public IS 'standard public schema';
--
-- Name: update_updated_at_column(); Type: FUNCTION; Schema: public; Owner: rw_main
--
CREATE FUNCTION public.update_updated_at_column() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.update_updated_at_column() OWNER TO rw_main;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: event; Type: TABLE; Schema: public; Owner: rw_main
--
CREATE TABLE public.event (
id integer NOT NULL,
start_time timestamp without time zone NOT NULL,
duration integer NOT NULL,
teacher_id integer NOT NULL,
price numeric(10,2) NOT NULL,
student_id integer NOT NULL,
description text,
approved_by_teacher boolean DEFAULT false,
skipped boolean DEFAULT false,
rating integer,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.event OWNER TO rw_main;
--
-- Name: event_id_seq; Type: SEQUENCE; Schema: public; Owner: rw_main
--
CREATE SEQUENCE public.event_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.event_id_seq OWNER TO rw_main;
--
-- Name: event_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rw_main
--
ALTER SEQUENCE public.event_id_seq OWNED BY public.event.id;
--
-- Name: homework_files; Type: TABLE; Schema: public; Owner: rw_main
--
CREATE TABLE public.homework_files (
id integer NOT NULL,
homework_id integer NOT NULL,
file_name character varying(255) NOT NULL,
file_path text NOT NULL,
uploaded_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.homework_files OWNER TO rw_main;
--
-- Name: homework_files_id_seq; Type: SEQUENCE; Schema: public; Owner: rw_main
--
CREATE SEQUENCE public.homework_files_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.homework_files_id_seq OWNER TO rw_main;
--
-- Name: homework_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rw_main
--
ALTER SEQUENCE public.homework_files_id_seq OWNED BY public.homework_files.id;
--
-- Name: homeworks; Type: TABLE; Schema: public; Owner: rw_main
--
CREATE TABLE public.homeworks (
id integer NOT NULL,
description text NOT NULL,
due_date timestamp without time zone NOT NULL,
student_id integer NOT NULL,
teacher_id integer NOT NULL,
rating integer,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.homeworks OWNER TO rw_main;
--
-- Name: homeworks_id_seq; Type: SEQUENCE; Schema: public; Owner: rw_main
--
CREATE SEQUENCE public.homeworks_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.homeworks_id_seq OWNER TO rw_main;
--
-- Name: homeworks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rw_main
--
ALTER SEQUENCE public.homeworks_id_seq OWNED BY public.homeworks.id;
--
-- Name: teacher_student; Type: TABLE; Schema: public; Owner: rw_main
--
CREATE TABLE public.teacher_student (
id integer NOT NULL,
teacher_id integer NOT NULL,
student_id integer NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.teacher_student OWNER TO rw_main;
--
-- Name: teacher_student_id_seq; Type: SEQUENCE; Schema: public; Owner: rw_main
--
CREATE SEQUENCE public.teacher_student_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.teacher_student_id_seq OWNER TO rw_main;
--
-- Name: teacher_student_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rw_main
--
ALTER SEQUENCE public.teacher_student_id_seq OWNED BY public.teacher_student.id;
--
-- Name: user; Type: TABLE; Schema: public; Owner: rw_main
--
CREATE TABLE public."user" (
id integer NOT NULL,
username character varying(255) NOT NULL,
password character varying(255) NOT NULL,
role integer NOT NULL,
invite_code character varying(255),
name character varying(255) NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public."user" OWNER TO rw_main;
--
-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: rw_main
--
CREATE SEQUENCE public.user_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.user_id_seq OWNER TO rw_main;
--
-- Name: user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rw_main
--
ALTER SEQUENCE public.user_id_seq OWNED BY public."user".id;
--
-- Name: event id; Type: DEFAULT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.event ALTER COLUMN id SET DEFAULT nextval('public.event_id_seq'::regclass);
--
-- Name: homework_files id; Type: DEFAULT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.homework_files ALTER COLUMN id SET DEFAULT nextval('public.homework_files_id_seq'::regclass);
--
-- Name: homeworks id; Type: DEFAULT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.homeworks ALTER COLUMN id SET DEFAULT nextval('public.homeworks_id_seq'::regclass);
--
-- Name: teacher_student id; Type: DEFAULT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.teacher_student ALTER COLUMN id SET DEFAULT nextval('public.teacher_student_id_seq'::regclass);
--
-- Name: user id; Type: DEFAULT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public."user" ALTER COLUMN id SET DEFAULT nextval('public.user_id_seq'::regclass);
--
-- Data for Name: event; Type: TABLE DATA; Schema: public; Owner: rw_main
--
--
-- Data for Name: homework_files; Type: TABLE DATA; Schema: public; Owner: rw_main
--
INSERT INTO public.homework_files (id, homework_id, file_name, file_path, uploaded_at) VALUES (11, 11, 'ТИ.pdf', 'uploads/homework/11_ТИ.pdf.pdf', '2025-04-22 00:48:03.430567');
--
-- Data for Name: homeworks; Type: TABLE DATA; Schema: public; Owner: rw_main
--
INSERT INTO public.homeworks (id, description, due_date, student_id, teacher_id, rating, created_at, updated_at) VALUES (9, 'Тестовое домашнее задание', '2025-04-23 00:00:00', 96, 95, NULL, '2025-04-22 00:23:08.533939', '2025-04-22 00:23:08.533939');
INSERT INTO public.homeworks (id, description, due_date, student_id, teacher_id, rating, created_at, updated_at) VALUES (10, 'Тестовое домашнее задание', '2025-04-23 00:00:00', 99, 98, NULL, '2025-04-22 00:26:20.967737', '2025-04-22 00:26:20.967737');
INSERT INTO public.homeworks (id, description, due_date, student_id, teacher_id, rating, created_at, updated_at) VALUES (11, 'test', '2025-04-30 00:00:00', 72, 71, 3, '2025-04-22 00:32:10.366758', '2025-04-22 00:42:46.13845');
--
-- Data for Name: teacher_student; Type: TABLE DATA; Schema: public; Owner: rw_main
--
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (8, 71, 72, '2025-04-22 00:11:02.193972');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (9, 74, 75, '2025-04-22 00:15:49.048226');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (10, 77, 78, '2025-04-22 00:16:16.65874');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (11, 80, 81, '2025-04-22 00:18:15.892062');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (12, 83, 84, '2025-04-22 00:19:08.826555');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (13, 86, 87, '2025-04-22 00:21:01.39769');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (14, 89, 90, '2025-04-22 00:21:58.283115');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (15, 92, 93, '2025-04-22 00:22:44.642627');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (16, 95, 96, '2025-04-22 00:23:08.520639');
INSERT INTO public.teacher_student (id, teacher_id, student_id, created_at) VALUES (17, 98, 99, '2025-04-22 00:26:20.951353');
--
-- Data for Name: user; Type: TABLE DATA; Schema: public; Owner: rw_main
--
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (72, 'test2@test.ru', '80eb26791e4fd74e71cb685f219d2e8bcf96a462f70dcac12562a99eedf5ae62dd42523022b786a82f27b43a6250a4b7f1662e9fe4378b0e341d9482d395f669', 1, 'CD57F5', 'Nikita Petrov', '2025-04-22 00:11:02.184003', '2025-04-22 00:11:02.184003');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (76, 'testuser_1745280973', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '8B25AF', 'Test User', '2025-04-22 00:16:13.592259', '2025-04-22 00:16:13.592259');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (78, 'student_1745280974', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '430758', 'Test Student', '2025-04-22 00:16:15.630775', '2025-04-22 00:16:15.630775');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (80, 'teacher_1745281093', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '26D769', 'Test Teacher', '2025-04-22 00:18:13.839757', '2025-04-22 00:18:13.839757');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (82, 'testuser_1745281145', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '170230', 'Test User', '2025-04-22 00:19:05.739213', '2025-04-22 00:19:05.739213');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (84, 'student_1745281146', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '9F5AE7', 'Test Student', '2025-04-22 00:19:07.791038', '2025-04-22 00:19:07.791038');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (88, 'testuser_1745281315', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, 'AD79FF', 'Test User', '2025-04-22 00:21:55.226097', '2025-04-22 00:21:55.226097');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (89, 'teacher_1745281316', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '3017EA', 'Test Teacher', '2025-04-22 00:21:56.241584', '2025-04-22 00:21:56.241584');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (90, 'student_1745281316', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '547F38', 'Test Student', '2025-04-22 00:21:57.256868', '2025-04-22 00:21:57.256868');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (91, 'testuser_1745281361', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '5F8FD1', 'Test User', '2025-04-22 00:22:41.562072', '2025-04-22 00:22:41.562072');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (93, 'student_1745281362', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, 'D77F73', 'Test Student', '2025-04-22 00:22:43.612883', '2025-04-22 00:22:43.612883');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (97, 'testuser_1745281577', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '469631', 'Test User', '2025-04-22 00:26:17.899461', '2025-04-22 00:26:17.899461');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (98, 'teacher_1745281578', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '9A8C99', 'Test Teacher', '2025-04-22 00:26:18.913182', '2025-04-22 00:26:18.913182');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (99, 'student_1745281578', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '8A2D2A', 'Test Student', '2025-04-22 00:26:19.92689', '2025-04-22 00:26:19.92689');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (73, 'testuser_1745280945', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '7F6203', 'Test User', '2025-04-22 00:15:45.984499', '2025-04-22 00:15:45.984499');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (74, 'teacher_1745280947', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '7129F8', 'Test Teacher', '2025-04-22 00:15:47.00502', '2025-04-22 00:15:47.00502');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (75, 'student_1745280947', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '951C2E', 'Test Student', '2025-04-22 00:15:48.018523', '2025-04-22 00:15:48.018523');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (77, 'teacher_1745280974', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '077BC8', 'Test Teacher', '2025-04-22 00:16:14.612506', '2025-04-22 00:16:14.612506');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (79, 'testuser_1745281092', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, 'DC104B', 'Test User', '2025-04-22 00:18:12.810485', '2025-04-22 00:18:12.810485');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (81, 'student_1745281093', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, 'BCA103', 'Test Student', '2025-04-22 00:18:14.863414', '2025-04-22 00:18:14.863414');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (83, 'teacher_1745281146', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, 'C824B5', 'Test Teacher', '2025-04-22 00:19:06.765978', '2025-04-22 00:19:06.765978');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (85, 'testuser_1745281258', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '4E7A4C', 'Test User', '2025-04-22 00:20:58.33461', '2025-04-22 00:20:58.33461');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (86, 'teacher_1745281259', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '7A9C92', 'Test Teacher', '2025-04-22 00:20:59.35437', '2025-04-22 00:20:59.35437');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (87, 'student_1745281259', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '38826B', 'Test Student', '2025-04-22 00:21:00.371785', '2025-04-22 00:21:00.371785');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (92, 'teacher_1745281362', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '04AA4C', 'Test Teacher', '2025-04-22 00:22:42.590414', '2025-04-22 00:22:42.590414');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (94, 'testuser_1745281385', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '219576', 'Test User', '2025-04-22 00:23:05.463139', '2025-04-22 00:23:05.463139');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (95, 'teacher_1745281386', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, 'EFB084', 'Test Teacher', '2025-04-22 00:23:06.48325', '2025-04-22 00:23:06.48325');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (96, 'student_1745281386', '0876e6c17ac41e68003af908be877b7a5178996eca7c91cac50fc825eef9ac5b018b9c862f7e3665317e60cc24d62a7cdd663ed7bfc22e782d565cc17190e101', 1, '9469D0', 'Test Student', '2025-04-22 00:23:07.493413', '2025-04-22 00:23:07.493413');
INSERT INTO public."user" (id, username, password, role, invite_code, name, created_at, updated_at) VALUES (71, 'test@test.ru', '80eb26791e4fd74e71cb685f219d2e8bcf96a462f70dcac12562a99eedf5ae62dd42523022b786a82f27b43a6250a4b7f1662e9fe4378b0e341d9482d395f669', 0, '389206', 'Иван Геннадьевич', '2025-04-22 00:10:36.334634', '2025-04-22 00:10:36.334634');
--
-- Name: event_id_seq; Type: SEQUENCE SET; Schema: public; Owner: rw_main
--
SELECT pg_catalog.setval('public.event_id_seq', 1, false);
--
-- Name: homework_files_id_seq; Type: SEQUENCE SET; Schema: public; Owner: rw_main
--
SELECT pg_catalog.setval('public.homework_files_id_seq', 11, true);
--
-- Name: homeworks_id_seq; Type: SEQUENCE SET; Schema: public; Owner: rw_main
--
SELECT pg_catalog.setval('public.homeworks_id_seq', 11, true);
--
-- Name: teacher_student_id_seq; Type: SEQUENCE SET; Schema: public; Owner: rw_main
--
SELECT pg_catalog.setval('public.teacher_student_id_seq', 17, true);
--
-- Name: user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: rw_main
--
SELECT pg_catalog.setval('public.user_id_seq', 99, true);
--
-- Name: event event_pkey; Type: CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.event
ADD CONSTRAINT event_pkey PRIMARY KEY (id);
--
-- Name: homework_files homework_files_pkey; Type: CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.homework_files
ADD CONSTRAINT homework_files_pkey PRIMARY KEY (id);
--
-- Name: homeworks homeworks_pkey; Type: CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.homeworks
ADD CONSTRAINT homeworks_pkey PRIMARY KEY (id);
--
-- Name: teacher_student teacher_student_pkey; Type: CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.teacher_student
ADD CONSTRAINT teacher_student_pkey PRIMARY KEY (id);
--
-- Name: teacher_student teacher_student_teacher_id_student_id_key; Type: CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.teacher_student
ADD CONSTRAINT teacher_student_teacher_id_student_id_key UNIQUE (teacher_id, student_id);
--
-- Name: user user_pkey; Type: CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public."user"
ADD CONSTRAINT user_pkey PRIMARY KEY (id);
--
-- Name: user user_username_key; Type: CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public."user"
ADD CONSTRAINT user_username_key UNIQUE (username);
--
-- Name: idx_event_start_time; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_event_start_time ON public.event USING btree (start_time);
--
-- Name: idx_event_student_id; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_event_student_id ON public.event USING btree (student_id);
--
-- Name: idx_event_teacher_id; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_event_teacher_id ON public.event USING btree (teacher_id);
--
-- Name: idx_homework_files_homework_id; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_homework_files_homework_id ON public.homework_files USING btree (homework_id);
--
-- Name: idx_homeworks_student_id; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_homeworks_student_id ON public.homeworks USING btree (student_id);
--
-- Name: idx_homeworks_teacher_id; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_homeworks_teacher_id ON public.homeworks USING btree (teacher_id);
--
-- Name: idx_teacher_student_student_id; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_teacher_student_student_id ON public.teacher_student USING btree (student_id);
--
-- Name: idx_teacher_student_teacher_id; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_teacher_student_teacher_id ON public.teacher_student USING btree (teacher_id);
--
-- Name: idx_user_invite_code; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_user_invite_code ON public."user" USING btree (invite_code);
--
-- Name: idx_user_username; Type: INDEX; Schema: public; Owner: rw_main
--
CREATE INDEX idx_user_username ON public."user" USING btree (username);
--
-- Name: event update_event_updated_at; Type: TRIGGER; Schema: public; Owner: rw_main
--
CREATE TRIGGER update_event_updated_at BEFORE UPDATE ON public.event FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
--
-- Name: homeworks update_homeworks_updated_at; Type: TRIGGER; Schema: public; Owner: rw_main
--
CREATE TRIGGER update_homeworks_updated_at BEFORE UPDATE ON public.homeworks FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
--
-- Name: user update_user_updated_at; Type: TRIGGER; Schema: public; Owner: rw_main
--
CREATE TRIGGER update_user_updated_at BEFORE UPDATE ON public."user" FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
--
-- Name: event event_student_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.event
ADD CONSTRAINT event_student_id_fkey FOREIGN KEY (student_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- Name: event event_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.event
ADD CONSTRAINT event_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- Name: homework_files homework_files_homework_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.homework_files
ADD CONSTRAINT homework_files_homework_id_fkey FOREIGN KEY (homework_id) REFERENCES public.homeworks(id) ON DELETE CASCADE;
--
-- Name: homeworks homeworks_student_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.homeworks
ADD CONSTRAINT homeworks_student_id_fkey FOREIGN KEY (student_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- Name: homeworks homeworks_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.homeworks
ADD CONSTRAINT homeworks_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- Name: teacher_student teacher_student_student_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.teacher_student
ADD CONSTRAINT teacher_student_student_id_fkey FOREIGN KEY (student_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- Name: teacher_student teacher_student_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rw_main
--
ALTER TABLE ONLY public.teacher_student
ADD CONSTRAINT teacher_student_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public."user"(id) ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--
File diff suppressed because one or more lines are too long
+368
View File
@@ -0,0 +1,368 @@
-- Downloaded from: https://github.com/rmarquez123/titans/blob/f498987acd658bfd6555a2026b4f0c3ae24872b6/docker/terrabyte.database/titans.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.6
-- Dumped by pg_dump version 15.2
-- Started on 2024-01-23 17:49:56
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;
--
-- TOC entry 10 (class 2615 OID 1128245)
-- Name: postgis; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA postgis;
ALTER SCHEMA postgis OWNER TO postgres;
--
-- TOC entry 11 (class 2615 OID 1137946)
-- Name: projects; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA projects;
ALTER SCHEMA projects OWNER TO postgres;
--
-- TOC entry 7 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
--
-- *not* creating schema, since initdb creates it
ALTER SCHEMA public OWNER TO postgres;
--
-- TOC entry 9 (class 2615 OID 1125424)
-- Name: users; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA users;
ALTER SCHEMA users OWNER TO postgres;
--
-- TOC entry 2 (class 3079 OID 1128246)
-- Name: postgis; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA postgis;
--
-- TOC entry 4338 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions';
SET default_tablespace = '';
--
-- TOC entry 231 (class 1259 OID 1137947)
-- Name: project; Type: TABLE; Schema: projects; Owner: postgres
--
CREATE TABLE projects.project (
project_id integer NOT NULL,
name character varying NOT NULL
);
ALTER TABLE projects.project OWNER TO postgres;
--
-- TOC entry 232 (class 1259 OID 1137955)
-- Name: project_envelope; Type: TABLE; Schema: projects; Owner: postgres
--
CREATE TABLE projects.project_envelope (
project_id integer NOT NULL,
lowerleft point NOT NULL,
upperright point NOT NULL,
srid integer NOT NULL
);
ALTER TABLE projects.project_envelope OWNER TO postgres;
--
-- TOC entry 233 (class 1259 OID 1137965)
-- Name: projectdatasource; Type: TABLE; Schema: projects; Owner: postgres
--
CREATE TABLE projects.projectdatasource (
project_id integer NOT NULL,
rastergroup_id integer NOT NULL
);
ALTER TABLE projects.projectdatasource OWNER TO postgres;
--
-- TOC entry 207 (class 1259 OID 1125447)
-- Name: raster_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.raster_id_seq
START WITH 0
INCREMENT BY 1
MINVALUE 0
MAXVALUE 1000000
CACHE 1;
ALTER TABLE public.raster_id_seq OWNER TO postgres;
--
-- TOC entry 208 (class 1259 OID 1125450)
-- Name: rastergeomproperties_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.rastergeomproperties_id_seq
START WITH 0
INCREMENT BY 1
MINVALUE 0
MAXVALUE 1000000
CACHE 1;
ALTER TABLE public.rastergeomproperties_id_seq OWNER TO postgres;
--
-- TOC entry 202 (class 1259 OID 1125392)
-- Name: raster; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.raster (
raster_id integer DEFAULT nextval('public.raster_id_seq'::regclass) NOT NULL,
rastertype_id integer NOT NULL,
source_id integer NOT NULL,
rastergeomproperties_id integer DEFAULT nextval('public.rastergeomproperties_id_seq'::regclass) NOT NULL
);
ALTER TABLE public.raster OWNER TO postgres;
--
-- TOC entry 203 (class 1259 OID 1125397)
-- Name: rastergeomproperties; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.rastergeomproperties (
rastergeomproperties_id integer DEFAULT nextval('public.rastergeomproperties_id_seq'::regclass) NOT NULL,
dx double precision NOT NULL,
dy double precision NOT NULL,
lowerleft point NOT NULL,
upperright point NOT NULL,
srid integer NOT NULL
);
ALTER TABLE public.rastergeomproperties OWNER TO postgres;
--
-- TOC entry 209 (class 1259 OID 1125455)
-- Name: rastergroup_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.rastergroup_id_seq
START WITH 0
INCREMENT BY 1
MINVALUE 0
MAXVALUE 1000000
CACHE 1;
ALTER TABLE public.rastergroup_id_seq OWNER TO postgres;
--
-- TOC entry 204 (class 1259 OID 1125419)
-- Name: rastergroup; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.rastergroup (
rastergroup_id integer DEFAULT nextval('public.rastergroup_id_seq'::regclass) NOT NULL,
name character varying(200) NOT NULL
);
ALTER TABLE public.rastergroup OWNER TO postgres;
--
-- TOC entry 210 (class 1259 OID 1125462)
-- Name: rastergroup_by_user_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.rastergroup_by_user_id_seq
START WITH 0
INCREMENT BY 1
MINVALUE 0
MAXVALUE 1000000
CACHE 1;
ALTER TABLE public.rastergroup_by_user_id_seq OWNER TO postgres;
--
-- TOC entry 206 (class 1259 OID 1125430)
-- Name: rastergroup_by_user; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.rastergroup_by_user (
rastergroup_by_user_id integer DEFAULT nextval('public.rastergroup_by_user_id_seq'::regclass) NOT NULL,
rastergroup_id integer NOT NULL,
user_id integer NOT NULL
);
ALTER TABLE public.rastergroup_by_user OWNER TO postgres;
--
-- TOC entry 214 (class 1259 OID 1125476)
-- Name: rastergroup_raster_link; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.rastergroup_raster_link (
rastergroup_id integer NOT NULL,
raster_id integer NOT NULL
);
ALTER TABLE public.rastergroup_raster_link OWNER TO postgres;
--
-- TOC entry 211 (class 1259 OID 1125465)
-- Name: rastertype_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.rastertype_id_seq
START WITH 0
INCREMENT BY 1
MINVALUE 0
MAXVALUE 1000000
CACHE 1;
ALTER TABLE public.rastertype_id_seq OWNER TO postgres;
--
-- TOC entry 200 (class 1259 OID 1125372)
-- Name: rastertype; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.rastertype (
rastertype_id integer DEFAULT nextval('public.rastertype_id_seq'::regclass) NOT NULL,
name character varying(200) NOT NULL
);
ALTER TABLE public.rastertype OWNER TO postgres;
--
-- TOC entry 212 (class 1259 OID 1125468)
-- Name: source_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.source_id_seq
START WITH 0
INCREMENT BY 1
MINVALUE 0
MAXVALUE 1000000
CACHE 1;
ALTER TABLE public.source_id_seq OWNER TO postgres;
--
-- TOC entry 201 (class 1259 OID 1125377)
-- Name: source; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.source (
source_id integer DEFAULT nextval('public.source_id_seq'::regclass) NOT NULL,
title character varying(200) NOT NULL,
description character varying(200)
);
ALTER TABLE public.source OWNER TO postgres;
--
-- TOC entry 230 (class 1259 OID 1129754)
-- Name: authentication; Type: TABLE; Schema: users; Owner: postgres
--
CREATE TABLE users.authentication (
user_id integer NOT NULL,
key character varying(200) NOT NULL
);
ALTER TABLE users.authentication OWNER TO postgres;
--
-- TOC entry 213 (class 1259 OID 1125473)
-- Name: user_id_seq; Type: SEQUENCE; Schema: users; Owner: postgres
--
CREATE SEQUENCE users.user_id_seq
START WITH 0
INCREMENT BY 1
MINVALUE 0
MAXVALUE 1000000
CACHE 1;
ALTER TABLE users.user_id_seq OWNER TO postgres;
--
-- TOC entry 205 (class 1259 OID 1125425)
-- Name: user; Type: TABLE; Schema: users; Owner: postgres
--
CREATE TABLE users."user" (
user_id integer DEFAULT nextval('users.user_id_seq'::regclass) NOT NULL,
name character varying(200) NOT NULL,
email character varying(200)
);
ALTER TABLE users."user" OWNER TO postgres;
--
-- TOC entry 4337 (class 0 OID 0)
-- Dependencies: 7
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE USAGE ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;
-- Completed on 2024-01-23 17:49:56
--
-- PostgreSQL database dump complete
--
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,522 @@
-- Downloaded from: https://github.com/the-benchmarker/web-frameworks/blob/cdfda22d3f2593f7e9a634504e7e0aeb1750a1fb/dump.sql
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.5
-- Dumped by pg_dump version 11.5
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;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.ar_internal_metadata (
key character varying NOT NULL,
value character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);
ALTER TABLE public.ar_internal_metadata OWNER TO postgres;
--
-- Name: concurrencies; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.concurrencies (
id bigint NOT NULL,
level numeric
);
ALTER TABLE public.concurrencies OWNER TO postgres;
--
-- Name: concurrencies_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.concurrencies_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.concurrencies_id_seq OWNER TO postgres;
--
-- Name: concurrencies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.concurrencies_id_seq OWNED BY public.concurrencies.id;
--
-- Name: frameworks; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.frameworks (
id bigint NOT NULL,
language_id bigint,
label character varying
);
ALTER TABLE public.frameworks OWNER TO postgres;
--
-- Name: frameworks_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.frameworks_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.frameworks_id_seq OWNER TO postgres;
--
-- Name: frameworks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.frameworks_id_seq OWNED BY public.frameworks.id;
--
-- Name: keys; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.keys (
id bigint NOT NULL,
label character varying
);
ALTER TABLE public.keys OWNER TO postgres;
--
-- Name: keys_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.keys_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.keys_id_seq OWNER TO postgres;
--
-- Name: keys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.keys_id_seq OWNED BY public.keys.id;
--
-- Name: languages; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.languages (
id bigint NOT NULL,
label character varying
);
ALTER TABLE public.languages OWNER TO postgres;
--
-- Name: languages_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.languages_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.languages_id_seq OWNER TO postgres;
--
-- Name: languages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.languages_id_seq OWNED BY public.languages.id;
--
-- Name: metrics; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.metrics (
framework_id bigint,
value_id bigint,
concurrency_id bigint
);
ALTER TABLE public.metrics OWNER TO postgres;
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.schema_migrations (
version character varying NOT NULL
);
ALTER TABLE public.schema_migrations OWNER TO postgres;
--
-- Name: values; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public."values" (
id bigint NOT NULL,
value numeric,
key_id bigint
);
ALTER TABLE public."values" OWNER TO postgres;
--
-- Name: values_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.values_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.values_id_seq OWNER TO postgres;
--
-- Name: values_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.values_id_seq OWNED BY public."values".id;
--
-- Name: writable; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.writable (
language_id bigint,
framework_id bigint
);
ALTER TABLE public.writable OWNER TO postgres;
--
-- Name: concurrencies id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.concurrencies ALTER COLUMN id SET DEFAULT nextval('public.concurrencies_id_seq'::regclass);
--
-- Name: frameworks id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.frameworks ALTER COLUMN id SET DEFAULT nextval('public.frameworks_id_seq'::regclass);
--
-- Name: keys id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.keys ALTER COLUMN id SET DEFAULT nextval('public.keys_id_seq'::regclass);
--
-- Name: languages id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.languages ALTER COLUMN id SET DEFAULT nextval('public.languages_id_seq'::regclass);
--
-- Name: values id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."values" ALTER COLUMN id SET DEFAULT nextval('public.values_id_seq'::regclass);
--
-- Data for Name: ar_internal_metadata; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.ar_internal_metadata (key, value, created_at, updated_at) FROM stdin;
environment default_env 2020-02-09 14:44:04.669806 2020-02-09 14:44:04.669806
\.
--
-- Data for Name: concurrencies; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.concurrencies (id, level) FROM stdin;
\.
--
-- Data for Name: frameworks; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.frameworks (id, language_id, label) FROM stdin;
\.
--
-- Data for Name: keys; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.keys (id, label) FROM stdin;
\.
--
-- Data for Name: languages; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.languages (id, label) FROM stdin;
\.
--
-- Data for Name: metrics; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.metrics (framework_id, value_id, concurrency_id) FROM stdin;
\.
--
-- Data for Name: schema_migrations; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.schema_migrations (version) FROM stdin;
20191014111447
20200209161533
\.
--
-- Data for Name: values; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public."values" (id, value, key_id) FROM stdin;
\.
--
-- Data for Name: writable; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.writable (language_id, framework_id) FROM stdin;
\.
--
-- Name: concurrencies_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.concurrencies_id_seq', 1, false);
--
-- Name: frameworks_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.frameworks_id_seq', 1, false);
--
-- Name: keys_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.keys_id_seq', 1, false);
--
-- Name: languages_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.languages_id_seq', 1, false);
--
-- Name: values_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.values_id_seq', 1, false);
--
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.ar_internal_metadata
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
--
-- Name: concurrencies concurrencies_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.concurrencies
ADD CONSTRAINT concurrencies_pkey PRIMARY KEY (id);
--
-- Name: frameworks frameworks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.frameworks
ADD CONSTRAINT frameworks_pkey PRIMARY KEY (id);
--
-- Name: keys keys_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.keys
ADD CONSTRAINT keys_pkey PRIMARY KEY (id);
--
-- Name: languages languages_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.languages
ADD CONSTRAINT languages_pkey PRIMARY KEY (id);
--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
--
-- Name: values values_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public."values"
ADD CONSTRAINT values_pkey PRIMARY KEY (id);
--
-- Name: index_concurrencies_on_level; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX index_concurrencies_on_level ON public.concurrencies USING btree (level);
--
-- Name: index_frameworks_on_language_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX index_frameworks_on_language_id ON public.frameworks USING btree (language_id);
--
-- Name: index_frameworks_on_language_id_and_label; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX index_frameworks_on_language_id_and_label ON public.frameworks USING btree (language_id, label);
--
-- Name: index_keys_on_label; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX index_keys_on_label ON public.keys USING btree (label);
--
-- Name: index_languages_on_label; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX index_languages_on_label ON public.languages USING btree (label);
--
-- Name: index_metrics_on_concurrency_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX index_metrics_on_concurrency_id ON public.metrics USING btree (concurrency_id);
--
-- Name: index_metrics_on_framework_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX index_metrics_on_framework_id ON public.metrics USING btree (framework_id);
--
-- Name: index_metrics_on_value_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX index_metrics_on_value_id ON public.metrics USING btree (value_id);
--
-- Name: index_values_on_key_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX index_values_on_key_id ON public."values" USING btree (key_id);
--
-- Name: index_writable_on_framework_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX index_writable_on_framework_id ON public.writable USING btree (framework_id);
--
-- Name: index_writable_on_language_id; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX index_writable_on_language_id ON public.writable USING btree (language_id);
--
-- PostgreSQL database dump complete
--

Some files were not shown because too many files have changed in this diff Show More