Add migrations and model go struct
This commit is contained in:
		
							parent
							
								
									9d8914bf26
								
							
						
					
					
						commit
						1524ebced8
					
				@ -7,4 +7,4 @@ log_level: "debug"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# db
 | 
					# db
 | 
				
			||||||
DB:
 | 
					DB:
 | 
				
			||||||
  baseurlbd: "host=localhost user=tester dbname=testdb sslmode=disable"
 | 
					  baseurlbd: "host=localhost user=admin password=root dbname=postgres sslmode=disable"
 | 
				
			||||||
							
								
								
									
										12
									
								
								docker-compose.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								docker-compose.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					version: '3.5'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					services:
 | 
				
			||||||
 | 
					  database:
 | 
				
			||||||
 | 
					    container_name: postgres
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					      - "5432:5432"
 | 
				
			||||||
 | 
					    environment:
 | 
				
			||||||
 | 
					    - POSTGRES_PASSWORD=root
 | 
				
			||||||
 | 
					    - POSTGRES_USER=admin
 | 
				
			||||||
 | 
					    image: postgres
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
							
								
								
									
										21
									
								
								internal/bd/model/films.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								internal/bd/model/films.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Films struct {
 | 
				
			||||||
 | 
						id                       int
 | 
				
			||||||
 | 
						ru_title                 string
 | 
				
			||||||
 | 
						orig_title               string
 | 
				
			||||||
 | 
						imdb_id                  string
 | 
				
			||||||
 | 
						kinopoisk_id             string
 | 
				
			||||||
 | 
						posterUrl                string
 | 
				
			||||||
 | 
						posterUrlPreview         string
 | 
				
			||||||
 | 
						countries                string
 | 
				
			||||||
 | 
						genres                   map[string]interface{}
 | 
				
			||||||
 | 
						year                     int
 | 
				
			||||||
 | 
						description              string
 | 
				
			||||||
 | 
						ratingKinopoisk          int
 | 
				
			||||||
 | 
						ratingImdb               int
 | 
				
			||||||
 | 
						iframe_src               string
 | 
				
			||||||
 | 
						ratingImdbVoteCount      int
 | 
				
			||||||
 | 
						ratingKinopoiskVoteCount int
 | 
				
			||||||
 | 
						media                    map[string]interface{}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										18
									
								
								internal/bd/repositoryes/filmsrepo.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								internal/bd/repositoryes/filmsrepo.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					package repositoryes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"git.ukamnya.ru/stulyaganov/RestApi/internal/bd"
 | 
				
			||||||
 | 
						"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Filmsrepo struct {
 | 
				
			||||||
 | 
						DB *bd.Bd
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func Create(model.Films) (*model.Films, error) {
 | 
				
			||||||
 | 
						return nil, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func FindDyId(id int) (*model.Films, error) {
 | 
				
			||||||
 | 
						return nil, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										1
									
								
								migrates/20221213130458_films.down.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								migrates/20221213130458_films.down.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					DROP TABLE films;
 | 
				
			||||||
							
								
								
									
										21
									
								
								migrates/20221213130458_films.up.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								migrates/20221213130458_films.up.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE films (
 | 
				
			||||||
 | 
					    id INTEGER NOT NULL,
 | 
				
			||||||
 | 
					    ru_title VARCHAR(256),
 | 
				
			||||||
 | 
					    orig_title VARCHAR(255),
 | 
				
			||||||
 | 
					    imdb_id VARCHAR(255),
 | 
				
			||||||
 | 
					    kinopoisk_id INTEGER,
 | 
				
			||||||
 | 
					    posterUrl VARCHAR(1500),
 | 
				
			||||||
 | 
					    posterUrlPreview VARCHAR(1500),
 | 
				
			||||||
 | 
					    countries JSON,
 | 
				
			||||||
 | 
					    genres JSON,
 | 
				
			||||||
 | 
					    year INTEGER,
 | 
				
			||||||
 | 
					    description VARCHAR(20000),
 | 
				
			||||||
 | 
					    ratingKinopoisk INTEGER,
 | 
				
			||||||
 | 
					    ratingImdb INTEGER,
 | 
				
			||||||
 | 
					    iframe_src VARCHAR(2000),
 | 
				
			||||||
 | 
					    ratingImdbVoteCount INTEGER,
 | 
				
			||||||
 | 
					    ratingKinopoiskVoteCount INTEGER,
 | 
				
			||||||
 | 
					    media JSON,
 | 
				
			||||||
 | 
					    PRIMARY KEY(id)
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user